diff --git a/add-on/manifest.json b/add-on/manifest.json index 4c87c693e..83839d25d 100644 --- a/add-on/manifest.json +++ b/add-on/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "__MSG_manifest_extensionName__", "short_name": "__MSG_manifest_shortExtensionName__", - "version" : "2.1.0", + "version" : "2.1.1", "description": "__MSG_manifest_extensionDescription__", "homepage_url": "https://github.com/ipfs/ipfs-companion", diff --git a/add-on/src/lib/ipfs-request.js b/add-on/src/lib/ipfs-request.js index fa0423b07..f9e859e0c 100644 --- a/add-on/src/lib/ipfs-request.js +++ b/add-on/src/lib/ipfs-request.js @@ -13,6 +13,11 @@ function createRequestModifier (getState, dnsLink, ipfsPathValidator) { return } + // skip all local requests + if (request.url.startsWith('http://127.0.0.1:') || request.url.startsWith('http://localhost:')) { + return + } + // poor-mans protocol handlers - https://github.com/ipfs/ipfs-companion/issues/164#issuecomment-328374052 if (state.catchUnhandledProtocols && mayContainUnhandledIpfsProtocol(request)) { const fix = normalizedUnhandledIpfsProtocol(request, state.pubGwURLString) diff --git a/add-on/src/lib/options.js b/add-on/src/lib/options.js index 1ec63772e..ec3a5771b 100644 --- a/add-on/src/lib/options.js +++ b/add-on/src/lib/options.js @@ -9,8 +9,8 @@ const optionDefaults = Object.freeze({ preloadAtPublicGateway: true, catchUnhandledProtocols: true, displayNotifications: true, - customGatewayUrl: 'http://127.0.0.1:8080', - ipfsApiUrl: 'http://127.0.0.1:5001', + customGatewayUrl: 'http://localhost:8080', + ipfsApiUrl: 'http://localhost:5001', ipfsApiPollMs: 3000 }) @@ -42,3 +42,12 @@ function storeMissingOptions (read, defaults, storage) { } exports.storeMissingOptions = storeMissingOptions + +function normalizeGatewayURL (url) { + // https://github.com/ipfs/ipfs-companion/issues/291 + return url + .replace('/127.0.0.1:', '/localhost:') + .replace('/gateway.ipfs.io', '/ipfs.io') +} + +exports.normalizeGatewayURL = normalizeGatewayURL diff --git a/add-on/src/options/options.js b/add-on/src/options/options.js index 4c14196b4..35ed33925 100644 --- a/add-on/src/options/options.js +++ b/add-on/src/options/options.js @@ -2,7 +2,7 @@ /* eslint-env browser, webextensions */ const browser = require('webextension-polyfill') -const { optionDefaults } = require('../lib/options') +const { optionDefaults, normalizeGatewayURL } = require('../lib/options') const translateDataAttrs = require('../lib/data-i18n') translateDataAttrs() @@ -18,9 +18,11 @@ async function saveOption (name) { switch (element.type) { case 'text': case 'number': - case 'url': change[name] = element.value break + case 'url': + change[name] = normalizeGatewayURL(element.value) + break case 'textarea': // normalize input into a string of entries separated by a single space change[name] = element.value.replace(/[\r\n,;]+/g, ' ').replace(/ +(?= )/g, '').trim() diff --git a/add-on/src/popup/browser-action/gateway-status.js b/add-on/src/popup/browser-action/gateway-status.js index 2fa8ca3e4..9e4cd8393 100644 --- a/add-on/src/popup/browser-action/gateway-status.js +++ b/add-on/src/popup/browser-action/gateway-status.js @@ -15,7 +15,7 @@ module.exports = function gatewayStatus ({