Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
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
},