www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 325f0618d6d97388c889d3e3b52723bf8a21f83a
parent 6e439423855ffa63ad6159dfde3b1a4786bd874f
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date:   Thu, 20 Nov 2014 06:55:22 -0600

Resolve protocol-relative URLs outside of document context
by defaulting to HTTP

Diffstat:
Mchrome/content/zotero/xpcom/translation/translate.js | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js @@ -1208,16 +1208,22 @@ Zotero.Translate.Base.prototype = { } else { resolved = url; } - } else if(Zotero.isFx) { + } else if(Zotero.isFx && this.location) { resolved = Components.classes["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService). newURI(this.location, "", null).resolve(url); - } else if(Zotero.isNode) { + } else if(Zotero.isNode && this.location) { resolved = require('url').resolve(this.location, url); + } else if (this.document) { + var a = this.document.createElement('a'); + a.href = url; + resolved = a.href; + } else if (url.indexOf('//') == 0) { + // Protocol-relative URL with no associated web page + // Use HTTP by default + resolved = 'http:' + url; } else { - var a = document.createElement('a'); - a.href = url; - resolved = a.href; + throw new Error('Cannot resolve relative URL without an associated web page: ' + url); } /*var m = hostPortRe.exec(resolved);