From 1e94057c05fdb810017074f82346b5d971bf5e9f Mon Sep 17 00:00:00 2001 From: Jeffrey Jagoda Date: Thu, 26 Mar 2015 15:34:16 -0400 Subject: url: fix resolving from non-file to file URLs. When resolving a reference URL with the 'file' scheme an no host against a base URL without the 'file' scheme, the first path element of the reference URL is used as the host for the target URL. This results in an invalid target URL. This change makes an exception for file URLs so that the host is not mangled during URL resolution. PR-URL: https://github.com/iojs/io.js/pull/1277 Reviewed-By: Roman Reiss Reviewed-By: Ben Noordhuis Reviewed-By: Petka Antonov --- lib/url.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/url.js') diff --git a/lib/url.js b/lib/url.js index 82209db01c..1683f90503 100644 --- a/lib/url.js +++ b/lib/url.js @@ -495,7 +495,9 @@ Url.prototype.resolveObject = function(relative) { } result.protocol = relative.protocol; - if (!relative.host && !hostlessProtocol[relative.protocol]) { + if (!relative.host && + !/^file:?$/.test(relative.protocol) && + !hostlessProtocol[relative.protocol]) { var relPath = (relative.pathname || '').split('/'); while (relPath.length && !(relative.host = relPath.shift())); if (!relative.host) relative.host = ''; -- cgit v1.2.3