www

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

commit d5f3e6d8f74b4c9ea2e3af84fcb4369c70ce1e39
parent f2fb6e2e9c876408699944ec7be50987f5ca90bf
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon,  9 Mar 2015 20:41:18 -0400

Merge pull request #580 from aurimasv/relative-urls

Resolve protocol-relative URLs outside of document context
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 @@ -1249,16 +1249,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);