diff --git a/lib/url.js b/lib/url.js index 21d3acb348e5..8b01c8548f5b 100644 --- a/lib/url.js +++ b/lib/url.js @@ -54,9 +54,7 @@ var protocolPattern = /^([a-z0-9]+:)/i, // protocols that never have a hostname. hostlessProtocol = { 'javascript': true, - 'javascript:': true, - 'file': true, - 'file:': true + 'javascript:': true }, // protocols that always have a path component. pathedProtocol = { diff --git a/test/simple/test-url.js b/test/simple/test-url.js index 954454ffa8a5..ea85bc967fe2 100644 --- a/test/simple/test-url.js +++ b/test/simple/test-url.js @@ -166,12 +166,38 @@ var parseTests = { 'file:///etc/passwd' : { 'href': 'file:///etc/passwd', 'protocol': 'file:', - 'pathname': '///etc/passwd' + 'pathname': '/etc/passwd', + 'hostname': '' + }, + 'file://localhost/etc/passwd' : { + 'href': 'file://localhost/etc/passwd', + 'protocol': 'file:', + 'pathname': '/etc/passwd', + 'hostname': 'localhost' + }, + 'file://foo/etc/passwd' : { + 'href': 'file://foo/etc/passwd', + 'protocol': 'file:', + 'pathname': '/etc/passwd', + 'hostname': 'foo' }, 'file:///etc/node/' : { 'href': 'file:///etc/node/', 'protocol': 'file:', - 'pathname': '///etc/node/' + 'pathname': '/etc/node/', + 'hostname': '' + }, + 'file://localhost/etc/node/' : { + 'href': 'file://localhost/etc/node/', + 'protocol': 'file:', + 'pathname': '/etc/node/', + 'hostname': 'localhost' + }, + 'file://foo/etc/node/' : { + 'href': 'file://foo/etc/node/', + 'protocol': 'file:', + 'pathname': '/etc/node/', + 'hostname': 'foo' }, 'http:/baz/../foo/bar' : { 'href': 'http:/baz/../foo/bar',