summaryrefslogtreecommitdiff
path: root/lib/url.js
diff options
context:
space:
mode:
authorJeffrey Jagoda <jeffrey.jagoda@gmail.com>2015-03-26 15:34:16 -0400
committerPetka Antonov <petka_antonov@hotmail.com>2015-04-04 13:25:32 +0300
commit1e94057c05fdb810017074f82346b5d971bf5e9f (patch)
treed0bf259adecf9e2850cae862f5e8677a2df9a55a /lib/url.js
parent8c6c376a9403496a7e4aab3a667c708e3e65ea33 (diff)
downloadandroid-node-v8-1e94057c05fdb810017074f82346b5d971bf5e9f.tar.gz
android-node-v8-1e94057c05fdb810017074f82346b5d971bf5e9f.tar.bz2
android-node-v8-1e94057c05fdb810017074f82346b5d971bf5e9f.zip
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 <me@silverwind.io> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Petka Antonov <petka_antonov@hotmail.com>
Diffstat (limited to 'lib/url.js')
-rw-r--r--lib/url.js4
1 files changed, 3 insertions, 1 deletions
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 = '';