How to use the is-ipfs.ipnsUrl 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 / popup / browser-action / store.js View on Github external
try {
      let noIntegrationsHostnames = state.noIntegrationsHostnames
      // if we are on /ipns/fqdn.tld/ then use hostname from DNSLink
      const fqdn = state.currentDnslinkFqdn || state.currentFqdn
      if (noIntegrationsHostnames.includes(fqdn)) {
        noIntegrationsHostnames = noIntegrationsHostnames.filter(host => !host.endsWith(fqdn))
      } else {
        noIntegrationsHostnames.push(fqdn)
      }
      // console.dir('toggleSiteIntegrations', state)
      await browser.storage.local.set({ noIntegrationsHostnames })

      // TODO: remove below? does it still make sense in "integrations toggle" context?
      // Reload the current tab to apply updated redirect preference
      if (!state.currentDnslinkFqdn || !IsIpfs.ipnsUrl(state.currentTab.url)) {
        // No DNSLink, reload URL as-is
        await browser.tabs.reload(state.currentTab.id)
      } else {
        // DNSLinked websites require URL change
        // from  http?://gateway.tld/ipns/{fqdn}/some/path
        // to    http://{fqdn}/some/path
        // (defaulting to http: https websites will have HSTS or a redirect)
        const originalUrl = state.currentTab.url.replace(/^.*\/ipns\//, 'http://')
        await browser.tabs.update(state.currentTab.id, {
          // FF only: loadReplace: true,
          url: originalUrl
        })
      }
    } catch (error) {
      console.error(`Unable to update integrations state due to ${error}`)
      emitter.emit('render')
github ipfs-shipyard / ipfs-companion / add-on / src / lib / ipfs-path.js View on Github external
isRedirectPageActionsContext (url) {
      const state = getState()
      return state.ipfsNodeType !== 'embedded' && // hide with embedded node
      (IsIpfs.ipnsUrl(url) || // show on /ipns/
        (url.startsWith('http') && // hide on non-HTTP pages
         !url.startsWith(state.gwURLString) && // hide on /ipfs/*
          !url.startsWith(state.apiURLString))) // hide on api port
    },

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