Proxy code: ensure URL constructor in non-window JS scope

Closes #2924
This commit is contained in:
Adomas Venčkauskas 2022-11-21 10:23:58 +02:00
parent 1106685f2d
commit dfdc66a41c

View file

@ -138,8 +138,13 @@ Zotero.Proxies = new function() {
* @type String
*/
this.proxyToProper = function(url, onlyReturnIfProxied) {
// make sure url has a trailing slash
url = new URL(url).href;
// 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;
}
for (let proxy of Zotero.Proxies.proxies) {
if(proxy.regexp) {
var m = proxy.regexp.exec(url);
@ -179,10 +184,13 @@ Zotero.Proxies = new function() {
* @returns {Object} Unproxied url to proxy object
*/
this.getPotentialProxies = function(url) {
try {
// make sure url has a trailing slash
// 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;
} catch (e) { }
}
var urlToProxy = {};
// If it's a known proxied URL just return it
if (Zotero.Proxies.transparent) {