Skip to content

Commit

Permalink
fix: skip x-ipfs-path processing on active gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Sep 8, 2018
1 parent d80a06a commit b4cead0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion add-on/src/lib/ipfs-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ function createRequestModifier (getState, dnslinkResolver, ipfsPathValidator, ru
// Detect X-Ipfs-Path Header and upgrade transport to IPFS:
// 1. Check if DNSLink exists and redirect to it.
// 2. If there is no DNSLink, validate path from the header and redirect
if (state.detectIpfsPathHeader && request.responseHeaders && !request.url.startsWith(state.gwURLString) && !request.url.startsWith(state.apiURLString)) {
const url = request.url
const notActiveGatewayOrApi = !(url.startsWith(state.pubGwURLString) || url.startsWith(state.gwURLString) || url.startsWith(state.apiURLString))
if (state.detectIpfsPathHeader && request.responseHeaders && notActiveGatewayOrApi) {
// console.log('onHeadersReceived.request', request)
for (let header of request.responseHeaders) {
if (header.name.toLowerCase() === 'x-ipfs-path' && isSafeToRedirect(request, runtime)) {
Expand Down

0 comments on commit b4cead0

Please sign in to comment.