Skip to content

Commit

Permalink
fix: more strict custom protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Sep 17, 2017
1 parent f924f0a commit 56527f5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 102 deletions.
24 changes: 15 additions & 9 deletions add-on/src/lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ function onBeforeRequest (request) {
// handler for protocol_handlers from manifest.json
if (webPlusProtocolRequest(request)) {
// fix path passed via custom protocol
return normalizedWebPlusRequest(request)
const fix = normalizedWebPlusRequest(request)
if (fix) {
return fix
}
}

// handle redirects to custom gateway
Expand Down Expand Up @@ -126,18 +129,21 @@ function pathAtPublicGw (path) {
}

function normalizedWebPlusRequest (request) {
let path = decodeURIComponent(new URL(request.url).pathname)
path = path.replace(/^\/web\+fs:[/]*/i, '/') // web+fs://ipfs/Qm → /ipfs/Qm
path = path.replace(/^\/web\+dweb:[/]*/i, '/') // web+dweb://ipfs/Qm → /ipfs/Qm
path = path.replace(/^\/web\+([^:]+):[/]*/i, '/$1/') // web+foo://Qm → /foo/Qm
path = path.replace(/^\/ip([^/]+)\/ip[^/]+\//, '/ip$1/') // /ipfs/ipfs/Qm → /ipfs/Qm
return { redirectUrl: pathAtPublicGw(path) }
const oldPath = decodeURIComponent(new URL(request.url).pathname)
let path = oldPath
path = path.replace(/^\/web\+dweb:\//i, '/') // web+dweb:/ipfs/Qm → /ipfs/Qm
path = path.replace(/^\/web\+ipfs:\/\//i, '/ipfs/') // web+ipfs://Qm → /ipfs/Qm
path = path.replace(/^\/web\+ipns:\/\//i, '/ipns/') // web+ipns://Qm → /ipns/Qm
if (oldPath !== path && window.IsIpfs.path(path)) {
return { redirectUrl: pathAtPublicGw(path) }
}
return null
}

// PROTOCOL HANDLERS: UNIVERSAL FALLBACK FOR UNHANDLED PROTOCOLS
// ===================================================================

const unhandledIpfsRE = /=(?:web%2B|)(ipfs|ipns|fs|dweb)%3A(?:%2F|)(%2F[^&]+)/
const unhandledIpfsRE = /=(?:web%2B|)(ipfs(?=%3A%2F%2F)|ipns(?=%3A%2F%2F)|dweb(?=%3A%2Fip[f|n]s))%3A(?:%2F%2F|%2F)([^&]+)/

function mayContainUnhandledIpfsProtocol (request) {
// TODO: run only for google, bing, duckduckgo etc
Expand All @@ -149,7 +155,7 @@ function unhandledIpfsPath (requestUrl) {
const unhandled = requestUrl.match(unhandledIpfsRE)
if (unhandled && unhandled.length > 1) {
const unhandledProtocol = decodeURIComponent(unhandled[1])
const unhandledPath = decodeURIComponent(unhandled[2])
const unhandledPath = `/${decodeURIComponent(unhandled[2])}`
return window.IsIpfs.path(unhandledPath) ? unhandledPath : `/${unhandledProtocol}${unhandledPath}`
}
return null
Expand Down
136 changes: 43 additions & 93 deletions test/unit/01-onBeforeRequest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,164 +49,114 @@ describe('onBeforeRequest', function () {
})

describe('request made via "web+" handler from manifest.json/protocol_handlers', function () {
it('should be normalized if URI is web+ipfs:/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bipfs:/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
it('should not be normalized if URI is web+ipfs:/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+ipfs://{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
const request = url2request('https://ipfs.io/web%2Bipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
})
it('should be normalized if URI is web+ipns:/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bipns:/ipfs.io%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest')
it('should not be normalized if URI is web+ipns:/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bipns%3A%2Fipfs.io%3FargTest%23hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+ipns://{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bipns://ipfs.io%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest')
})
it('should be normalized if URI is web+fs:/ipfs/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bfs:/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
})
it('should be normalized if URI is web+fs://ipfs/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bfs://ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
})
it('should be normalized if URI is web+fs:/ipns/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bfs:/ipns/ipfs.io%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest')
})
it('should be normalized if URI is web+fs://ipns/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bfs://ipns/ipfs.io%3FargTest%23hashTest')
const request = url2request('https://ipfs.io/web%2Bipns%3A%2F%2Fipfs.io%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest')
})
it('should be normalized if URI is web+dweb:/ipfs/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bdweb:/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
const request = url2request('https://ipfs.io/web%2Bdweb%3A%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
})
it('should be normalized if URI is web+dweb://ipfs/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bdweb://ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
it('should not be normalized if URI is web+dweb://ipfs/{CID}', function () {
const request = url2request('https://ipfs.io/web%2Bdweb%3A%2F%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+dweb:/ipns/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bdweb:/ipns/ipfs.io%3FargTest%23hashTest')
const request = url2request('https://ipfs.io/web%2Bdweb%3A%2Fipns/ipfs.io%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest')
})
it('should be normalized if URI is web+dweb://ipns/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bdweb://ipns/ipfs.io%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest')
it('should not be normalized if URI is web+dweb://ipns/{foo}', function () {
const request = url2request('https://ipfs.io/web%2Bdweb%3A%2F%2Fipns/ipfs.io%3FargTest%23hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+{foo}:/bar', function () {
const request = url2request('https://ipfs.io/web%2Bfoo:/bar%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/foo/bar?argTest#hashTest')
it('should not be normalized if URI is web+{foo}:/bar', function () {
const request = url2request('https://ipfs.io/web%2Bfoo%3A%2Fbar%3FargTest%23hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+{foo}://bar', function () {
const request = url2request('https://ipfs.io/web%2Bfoo://bar%3FargTest%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/foo/bar?argTest#hashTest')
it('should not be normalized if URI is web+{foo}://bar', function () {
const request = url2request('https://ipfs.io/web%2Bfoo%3A%2F%2Fbar%3FargTest%23hashTest')
should.not.exist(onBeforeRequest(request))
})
})

// TODO: add tests for unhandled protocol schemes:
// - google, duck duck go, bing, baidu, yandex
describe('unhandled custom protocol request', function () {
it('should be normalized if URI is ipfs:/{CID}', function () {
describe('catching unhandled custom protocol request', function () {
it('should not be normalized if URI is ipfs:/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=ipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest&foo=bar')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is ipfs://{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=ipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest&foo=bar')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
})
it('should be normalized if URI is ipns:/{foo}', function () {
it('should not be normalized if URI is ipns:/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=ipns%3A%2Fipns.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipns.io/index.html?arg=foo&bar=buzz#hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is ipns://{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=ipns%3A%2F%2Fipns.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipns.io/index.html?arg=foo&bar=buzz#hashTest')
})
it('should be normalized if URI is fs:/ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=fs%3A%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is fs://ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=fs%3A%2F%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is fs:/ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=fs%3A%2F%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is fs://ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=fs%3A%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is dweb:/ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=dweb%3A%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is dweb://ipfs/{CID}', function () {
it('should not be normalized if URI is dweb://ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=dweb%3A%2F%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is dweb:/ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=dweb%3A%2F%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is dweb://ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=dweb%3A%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should not be normalized if URI is dweb://ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=dweb%3A%2F%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
should.not.exist(onBeforeRequest(request))
})

it('should be normalized if URI is web+ipfs:/{CID}', function () {
it('should not be normalized if URI is web+ipfs:/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest&foo=bar')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+ipfs://{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest&foo=bar')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest')
})
it('should be normalized if URI is web+ipns:/{foo}', function () {
it('should not be normalized if URI is web+ipns:/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bipns%3A%2Fipns.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipns.io/index.html?arg=foo&bar=buzz#hashTest')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+ipns://{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bipns%3A%2F%2Fipns.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hashTest')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipns.io/index.html?arg=foo&bar=buzz#hashTest')
})
it('should be normalized if URI is web+fs:/ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bfs%3A%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is web+fs://ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bfs%3A%2F%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is web+fs:/ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bfs%3A%2F%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is web+fs://ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bfs%3A%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is web+dweb:/ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bdweb%3A%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is web+dweb://ipfs/{CID}', function () {
it('should not be normalized if URI is web+dweb://ipfs/{CID}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bdweb%3A%2F%2Fipfs%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=software')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=foo&bar=buzz#hash')
should.not.exist(onBeforeRequest(request))
})
it('should be normalized if URI is web+dweb:/ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bdweb%3A%2F%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should be normalized if URI is web+dweb://ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bdweb%3A%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
onBeforeRequest(request).redirectUrl.should.equal('https://ipfs.io/ipns/ipfs.io/index.html?arg=foo&bar=buzz#hash')
})
it('should not be normalized if URI is web+dweb://ipns/{foo}', function () {
const request = url2request('https://duckduckgo.com/?q=web%2Bdweb%3A%2F%2Fipns%2Fipfs.io%2Findex.html%3Farg%3Dfoo%26bar%3Dbuzz%23hash&ia=web')
should.not.exist(onBeforeRequest(request))
})

it('should not be normalized if disabled in Preferences', function () {
state.catchUnhandledProtocols = false
Expand Down

0 comments on commit 56527f5

Please sign in to comment.