Merge pull request #19 from lidel/x-ipfs-no-redirect

Opt-out from gateway redirects done by IPFS Companion
merge-requests/2/merge
victorbjelkholm 2018-09-17 19:36:57 +02:00 committed by GitHub
commit 555d0de3c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

4
app.js
View File

@ -27,7 +27,9 @@ function checkGateways (gateways) {
let checked = 0 let checked = 0
gateways.forEach((gateway) => { gateways.forEach((gateway) => {
const gatewayAndHash = gateway.replace(':hash', hashToTest) const gatewayAndHash = gateway.replace(':hash', hashToTest)
fetch(gatewayAndHash) // opt-out from gateway redirects done by browser extension
const testUrl = gatewayAndHash + '#x-ipfs-companion-no-redirect'
fetch(testUrl)
.then(res => res.text()) .then(res => res.text())
.then((text) => { .then((text) => {
const matched = text.trim() === hashString.trim() const matched = text.trim() === hashString.trim()