diff options
author | Ryan Petrello <lists@ryanpetrello.com> | 2011-05-20 00:50:35 -0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-05-27 10:47:34 -0700 |
commit | 58a1d7ec30a5e26625f42c97c3cbe9134368605d (patch) | |
tree | 2dabdb93551bcf93674c700be4d4aef6f375551c /test | |
parent | eb4c9ed881cb93bc19401eb4270d113c4ba52d6b (diff) | |
download | node-new-58a1d7ec30a5e26625f42c97c3cbe9134368605d.tar.gz |
Close #562 Close #1078 Parse file:// urls properly
The file:// protocol *always* has a hostname; it's frequently
abbreviated as an empty string, which represents 'localhost'
implicitly.
According to RFC 1738 (http://tools.ietf.org/html/rfc1738):
A file URL takes the form:
file://<host>/<path>
where <host> is the fully qualified domain name of the system on
which the <path> is accessible...
As a special case, <host> can be the string "localhost" or the empty
string; this is interpreted as 'the machine from which the URL is
being interpreted'.
Diffstat (limited to 'test')
-rw-r--r-- | test/simple/test-url.js | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/simple/test-url.js b/test/simple/test-url.js index 954454ffa8..ea85bc967f 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', |