Make sure URL constructor is available in non-window environment

This commit is contained in:
Adomas Venčkauskas 2022-11-15 15:23:24 +02:00
parent ae14d433f9
commit c3c0b363c1

View file

@ -458,7 +458,12 @@ Zotero.Proxy.prototype.erase = Zotero.Promise.coroutine(function* () {
Zotero.Proxy.prototype.toProper = function(m) {
if (!Array.isArray(m)) {
// make sure url has a trailing slash
m = new URL(m).href;
if (typeof URL === 'undefined') {
m = new (Services.wm.getMostRecentWindow("navigator:browser")).URL(m).href;
}
else {
m = new URL(m).href;
}
let match = this.regexp.exec(m);
if (!match) {
return m