diff --git a/add-on/manifest.firefox.json b/add-on/manifest.firefox.json index 0b67a894d..369b2e45c 100644 --- a/add-on/manifest.firefox.json +++ b/add-on/manifest.firefox.json @@ -37,32 +37,32 @@ { "protocol": "web+dweb", "name": "IPFS Companion: DWEB Protocol Handler", - "uriTemplate": "https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#%s" + "uriTemplate": "https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#%s" }, { "protocol": "web+ipns", "name": "IPFS Companion: IPNS Protocol Handler", - "uriTemplate": "https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#%s" + "uriTemplate": "https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#%s" }, { "protocol": "web+ipfs", "name": "IPFS Companion: IPFS Protocol Handler", - "uriTemplate": "https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#%s" + "uriTemplate": "https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#%s" }, { "protocol": "dweb", "name": "IPFS Companion: DWEB Protocol Handler", - "uriTemplate": "https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#%s" + "uriTemplate": "https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#%s" }, { "protocol": "ipns", "name": "IPFS Companion: IPNS Protocol Handler", - "uriTemplate": "https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#%s" + "uriTemplate": "https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#%s" }, { "protocol": "ipfs", "name": "IPFS Companion: IPFS Protocol Handler", - "uriTemplate": "https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#%s" + "uriTemplate": "https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#%s" } ] } diff --git a/add-on/src/lib/ipfs-request.js b/add-on/src/lib/ipfs-request.js index 1a22640a1..526cced17 100644 --- a/add-on/src/lib/ipfs-request.js +++ b/add-on/src/lib/ipfs-request.js @@ -527,7 +527,7 @@ function isSafeToRedirect (request, runtime) { // This is just a placeholder that we had to provide -- removed in normalizedRedirectingProtocolRequest() // It has to match URL from manifest.json/protocol_handlers -const redirectingProtocolEndpoint = 'https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#' +const redirectingProtocolEndpoint = 'https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#' function redirectingProtocolRequest (request) { return request.url.startsWith(redirectingProtocolEndpoint) diff --git a/test/functional/lib/ipfs-request-protocol-handlers.test.js b/test/functional/lib/ipfs-request-protocol-handlers.test.js index c036b83fa..e7a6715d2 100644 --- a/test/functional/lib/ipfs-request-protocol-handlers.test.js +++ b/test/functional/lib/ipfs-request-protocol-handlers.test.js @@ -59,81 +59,81 @@ describe('modifyRequest.onBeforeRequest:', function () { // without web+ prefix (Firefox > 59: https://github.com/ipfs-shipyard/ipfs-companion/issues/164#issuecomment-356301174) it('should not be normalized if ipfs:/{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#ipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#ipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should be normalized if ipfs://{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#ipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#ipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest') }) it('should not be normalized if ipns:/{fqdn}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#ipns%3A%2Fipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#ipns%3A%2Fipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should be normalized if ipns://{fqdn}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#ipns%3A%2F%2Fipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#ipns%3A%2F%2Fipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest') }) it('should be normalized if ipfs://{fqdn}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#ipfs%3A%2F%2Fipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#ipfs%3A%2F%2Fipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest') }) it('should be normalized if dweb:/ipfs/{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#dweb%3A%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#dweb%3A%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest') }) it('should not be normalized if dweb://ipfs/{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#dweb%3A%2F%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#dweb%3A%2F%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should be normalized if dweb:/ipns/{foo}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#dweb%3A%2Fipns/ipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#dweb%3A%2Fipns/ipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest') }) it('should not be normalized if dweb://ipns/{foo}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#dweb%3A%2F%2Fipns/ipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#dweb%3A%2F%2Fipns/ipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) // web+ prefixed versions (Firefox < 59 and Chrome) it('should not be normalized if web+ipfs:/{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bipfs%3A%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should be normalized if web+ipfs://{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest') }) it('should not be normalized if web+ipns:/{foo}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bipns%3A%2Fipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bipns%3A%2Fipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should be normalized if web+ipns://{foo}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bipns%3A%2F%2Fipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bipns%3A%2F%2Fipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest') }) it('should be normalized if web+dweb:/ipfs/{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bdweb%3A%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bdweb%3A%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).to.equal('https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#hashTest') }) it('should not be normalized if web+dweb://ipfs/{CID}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bdweb%3A%2F%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bdweb%3A%2F%2Fipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should be normalized if web+dweb:/ipns/{foo}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bdweb%3A%2Fipns/ipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bdweb%3A%2Fipns/ipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request).redirectUrl).equal('https://ipfs.io/ipns/ipfs.io?argTest#hashTest') }) it('should not be normalized if web+dweb://ipns/{foo}', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bdweb%3A%2F%2Fipns/ipfs.io%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bdweb%3A%2F%2Fipns/ipfs.io%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should not be normalized if web+{foo}:/bar', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bfoo%3A%2Fbar%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bfoo%3A%2Fbar%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) it('should not be normalized if web+{foo}://bar', function () { - const request = url2request('https://gateway.ipfs.io/ipfs/QmVGC4uCBDVEhCzsaJmvR5nVDgChM97kcYNehVm7L9jxtc#web%2Bfoo%3A%2F%2Fbar%3FargTest%23hashTest') + const request = url2request('https://gateway.ipfs.io/ipfs/bafkreiacamq42cltx3ussmxb2ey3mmpisthrs3kelwuxnwt7oofvqsjvgm#web%2Bfoo%3A%2F%2Fbar%3FargTest%23hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) }) })