How to use the is-ipfs.subdomainPattern function in is-ipfs

To help you get started, we’ve selected a few is-ipfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs-shipyard / ipfs-companion / add-on / src / lib / ipfs-path.js View on Github external
function subdomainToIpfsPath (url) {
  if (typeof url === 'string') {
    url = new URL(url)
  }
  const match = url.toString().match(IsIpfs.subdomainPattern)
  if (!match) throw new Error('no match for IsIpfs.subdomainPattern')

  // TODO: support CID split with commas
  const cid = match[1]
  // TODO: support .ip(f|n)s. being at deeper levels
  const protocol = match[2]
  return `/${protocol}/${cid}${url.pathname}${url.search}${url.hash}`
}

is-ipfs

A set of utilities to help identify IPFS resources on the web

Apache-2.0 OR MIT
Latest version published 11 months ago

Package Health Score

64 / 100
Full package analysis