www

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

commit d47381512e642c5d981972f455565f3b0f6d1259
parent bf698c65c6cacba7ecb01adec85b35dbe541c59b
Author: Simon Kornblith <simon@simonster.com>
Date:   Sun, 10 Jul 2011 22:51:22 +0000

Fix relative URL resolution in Chrome/Safari/Node


Diffstat:
Mchrome/content/zotero/xpcom/utilities.js | 32++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js @@ -1325,23 +1325,27 @@ Zotero.Utilities.Translate.prototype._convertURL = function(url) { url = this._translate.translator[0].properToProxy(url); } - if(Zotero.isChrome || Zotero.isSafari) { - // this code is sandboxed, so we don't worry - return url; - } else { - if(protocolRe.test(url)) return url; - - // resolve local URL - var resolved = Components.classes["@mozilla.org/network/io-service;1"]. + if(protocolRe.test(url)) return url; + + // resolve local URL + var resolved = ""; + if(Zotero.isFx) { + resolved = Components.classes["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService). newURI(this._translate.location, "", null).resolve(url); - - if(!protocolRe.test(resolved)) { - throw new Error("Invalid URL supplied for HTTP request: "+url); - } - - return resolved; + } else if(Zotero.isChrome || Zotero.isSafari) { + var a = document.createElement('a'); + a.href = url; + resolved = a.href; + } else if(Zotero.isNode) { + resolved = require('url').resolve(this._translate.location, url); } + + if(!protocolRe.test(resolved)) { + throw new Error("Invalid URL supplied for HTTP request: "+url); + } + + return resolved; } Zotero.Utilities.Translate.prototype.__exposedProps__ = {"HTTP":"r"};