diff --git a/chrome/content/zotero/xpcom/proxy.js b/chrome/content/zotero/xpcom/proxy.js index 2cafe366bd..074090251e 100644 --- a/chrome/content/zotero/xpcom/proxy.js +++ b/chrome/content/zotero/xpcom/proxy.js @@ -23,6 +23,8 @@ ***** END LICENSE BLOCK ***** */ +Components.utils.importGlobalProperties(["URL"]); + /** * A singleton to handle URL rewriting proxies * @namespace @@ -139,12 +141,7 @@ Zotero.Proxies = new function() { */ this.proxyToProper = function(url, onlyReturnIfProxied) { // make sure url has a trailing slash - if (typeof URL === 'undefined') { - url = new (Services.wm.getMostRecentWindow("navigator:browser")).URL(url).href; - } - else { - url = new URL(url).href; - } + url = new URL(url).href; for (let proxy of Zotero.Proxies.proxies) { if(proxy.regexp) { var m = proxy.regexp.exec(url); @@ -185,12 +182,7 @@ Zotero.Proxies = new function() { */ this.getPotentialProxies = function(url) { // make sure url has a trailing slash - if (typeof URL === 'undefined') { - url = new (Services.wm.getMostRecentWindow("navigator:browser")).URL(url).href; - } - else { - url = new URL(url).href; - } + url = new URL(url).href; var urlToProxy = {}; // If it's a known proxied URL just return it if (Zotero.Proxies.transparent) { diff --git a/test/tests/proxyTest.js b/test/tests/proxyTest.js index 6cfc4d75a9..af07821487 100644 --- a/test/tests/proxyTest.js +++ b/test/tests/proxyTest.js @@ -11,20 +11,20 @@ describe("Zotero.Proxies", function(){ }); it("should return the provided url and deproxied url", function() { - let url = "https://www.example.com.proxy.example.com"; + let url = "https://www.example.com.proxy.example.com/"; let proxies = Zotero.Proxies.getPotentialProxies(url); let expectedProxies = {}; expectedProxies[url] = null; - expectedProxies["https://www.example.com"] = {scheme: "https://%h.proxy.example.com/%p"}; + expectedProxies["https://www.example.com/"] = {scheme: "https://%h.proxy.example.com/%p"}; assert.deepEqual(proxies, expectedProxies); }); it("should return the provided url and deproxied url with replaced hyphens", function() { - let url = "https://www-example-com.proxy.example.com"; + let url = "https://www-example-com.proxy.example.com/"; let proxies = Zotero.Proxies.getPotentialProxies(url); let expectedProxies = {}; expectedProxies[url] = null; - expectedProxies["https://www.example.com"] = {scheme: "https://%h.proxy.example.com/%p"}; + expectedProxies["https://www.example.com/"] = {scheme: "https://%h.proxy.example.com/%p"}; assert.deepEqual(proxies, expectedProxies); }); });