From 1f0b645b5fddcac822e9933e9b21f2e6903879f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sun, 15 Mar 2020 13:32:22 -0500 Subject: Change the HostMap key again --- js/vapi-background.js | 10 +++++----- lib/HostMap.jsm | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/vapi-background.js b/js/vapi-background.js index da32149..9611072 100644 --- a/js/vapi-background.js +++ b/js/vapi-background.js @@ -428,8 +428,9 @@ let channelData = this.channelDataFromChannel(channel); if (ηMatrix.userSettings.resolveCname === true) { - if (HostMap.get(URI)) { - this.operate(channel, HostMap.get(URI), topic); + let key = URI.scheme + '://' + URI.host; + if (HostMap.get(key)) { + this.operate(channel, HostMap.get(key), topic); return; } @@ -450,15 +451,14 @@ let addr = rec.canonicalName; ηMatrix.logger.writeOne(tab, 'info', - 'hostname "' + URI.host - + '" translated to ' + addr); + URI.host + ' => ' + addr); let ios = CC['@mozilla.org/network/io-service;1'] .createInstance(CI.nsIIOService); let uri = ios.newURI(URI.scheme+'://'+addr, null, null); - HostMap.put(URI, uri); + HostMap.put(key, uri); vAPI.httpObserver.operate(channel, uri, topic); }, diff --git a/lib/HostMap.jsm b/lib/HostMap.jsm index 59d4f65..ecbce25 100644 --- a/lib/HostMap.jsm +++ b/lib/HostMap.jsm @@ -31,7 +31,7 @@ var map = new Map(); var HostMap = { put: function (key, value) { - if (!(key instanceof Ci.nsIURI) || !(value instanceof Ci.nsIURI) + if (typeof key !== 'string' || !(value instanceof Ci.nsIURI) || !key || !value) { throw new Error('invalid argument(s)'); } @@ -43,7 +43,7 @@ var HostMap = { map.set(key, value); }, get: function (key) { - if (!(key instanceof Ci.nsIURI) || !key) { + if (typeof key !== 'string' || !key) { throw new Error('invalid argument'); } -- cgit v1.2.3