From f696599d219a907f768723c5cd64e3688db22cbe Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sun, 17 Jan 2016 00:28:18 +0100 Subject: [PATCH] FIX for false-positive href rewrites - Closes #43 --- lib/gateways.js | 2 ++ lib/protocols.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/gateways.js b/lib/gateways.js index e65241743..3f1a9fb3f 100644 --- a/lib/gateways.js +++ b/lib/gateways.js @@ -5,6 +5,8 @@ const {Cc, Ci} = require('chrome') const prefs = require('sdk/simple-prefs').prefs const ioservice = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService) +// TODO: replace regex with 3rd party library provided by IPFS community +// Ref. https://github.com/ipfs/notes/issues/92#issuecomment-172135885 const IPFS_RESOURCE = /^https?:\/\/[^\/]+\/ip(f|n)s\// exports.IPFS_RESOURCE = IPFS_RESOURCE diff --git a/lib/protocols.js b/lib/protocols.js index 93735fe8d..931803591 100644 --- a/lib/protocols.js +++ b/lib/protocols.js @@ -10,7 +10,9 @@ const IPNS_SCHEME = 'ipns' const FS_SCHEME = 'fs' const WEB_SCHEME_PREFIX = 'web+' // https://github.com/lidel/ipfs-firefox-addon/issues/36 -const IPFS_PATH = new RegExp('^/ip(f|n)s/') +// TODO: replace regex with 3rd party library provided by IPFS community +// Ref. https://github.com/ipfs/notes/issues/92#issuecomment-172135885 +const IPFS_PATH = new RegExp('^/(ipns/|ipfs/Qm[1-9A-HJ-NP-Za-km-z]{44})') function CommonProtocolHandler () {}