diff --git a/README.md b/README.md index 239797ba6..ee7581bfe 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ If tested path is a valid IPFS address it gets redirected and loaded from a loca It is possible to opt-out from redirect by a) suspending extension via global toggle -b) including `x-ipfs-no-redirect` in the URL ([as a hash or query parameter](https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?x-ipfs-no-redirect#x-ipfs-no-redirect)). +b) including `x-ipfs-companion-no-redirect` in the URL ([as a hash or query parameter](https://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?x-ipfs-companion-no-redirect#x-ipfs-companion-no-redirect)). #### IPFS API as `window.ipfs` diff --git a/add-on/src/lib/ipfs-request.js b/add-on/src/lib/ipfs-request.js index 753b6d505..0975a7dc4 100644 --- a/add-on/src/lib/ipfs-request.js +++ b/add-on/src/lib/ipfs-request.js @@ -3,7 +3,7 @@ const IsIpfs = require('is-ipfs') const { urlAtPublicGw } = require('./ipfs-path') -const redirectOptOutHint = 'x-ipfs-no-redirect' +const redirectOptOutHint = 'x-ipfs-companion-no-redirect' function createRequestModifier (getState, dnsLink, ipfsPathValidator, runtime) { // Request modifier provides event listeners for the various stages of making an HTTP request @@ -136,7 +136,7 @@ function redirectToGateway (requestUrl, state) { function isSafeToRedirect (request, runtime) { // Do not redirect if URL includes opt-out hint - if (request.url.includes('x-ipfs-no-redirect')) { + if (request.url.includes('x-ipfs-companion-no-redirect')) { return false } diff --git a/test/functional/lib/ipfs-request.test.js b/test/functional/lib/ipfs-request.test.js index 6d60e3877..6be3e535c 100644 --- a/test/functional/lib/ipfs-request.test.js +++ b/test/functional/lib/ipfs-request.test.js @@ -79,9 +79,9 @@ describe('modifyRequest.onBeforeRequest', function () { }) it(`should be left untouched if URL includes opt-out hint (${nodeType} node)`, function () { // A safe way for preloading data at arbitrary gateways - it should arrive at original destination - const request = url2request('https://google.com/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?x-ipfs-no-redirect#hashTest') + const request = url2request('https://google.com/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?x-ipfs-companion-no-redirect#hashTest') expect(modifyRequest.onBeforeRequest(request)).to.equal(undefined) - expect(redirectOptOutHint).to.equal('x-ipfs-no-redirect') + expect(redirectOptOutHint).to.equal('x-ipfs-companion-no-redirect') }) it(`should be left untouched if CID is invalid (${nodeType} node)`, function () { const request = url2request('https://google.com/ipfs/notacid?argTest#hashTest') @@ -89,7 +89,7 @@ describe('modifyRequest.onBeforeRequest', function () { }) it(`should be left untouched if its is a HEAD preload with explicit opt-out in URL hash (${nodeType} node)`, function () { // HTTP HEAD is a popular way for preloading data at arbitrary gateways, so we have a dedicated test to make sure it works as expected - const headRequest = {url: 'https://google.com/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#x-ipfs-no-redirect', method: 'HEAD'} + const headRequest = {url: 'https://google.com/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?argTest#x-ipfs-companion-no-redirect', method: 'HEAD'} expect(modifyRequest.onBeforeRequest(headRequest)).to.equal(undefined) }) })