diff options
author | isaacs <i@izs.me> | 2011-07-19 22:56:44 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-07-19 22:56:44 +0400 |
commit | ddfc6b78cc15202789e58b9220c1897e9d9aa525 (patch) | |
tree | c7fbb2b20b863ee42cc2ce702e97de2061fefcd2 | |
parent | 973153d1ccdbb06f9067f3698578e8a5685a87c4 (diff) |
Close #1360 url: Allow _ in hostnames.
-rw-r--r-- | lib/url.js | 4 | ||||
-rw-r--r-- | test/simple/test-url.js | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/url.js b/lib/url.js index 8b01c8548f5..6a26ed314b9 100644 --- a/lib/url.js +++ b/lib/url.js @@ -44,8 +44,8 @@ var protocolPattern = /^([a-z0-9]+:)/i, .concat(unwise).concat(autoEscape), nonAuthChars = ['/', '@', '?', '#'].concat(delims), hostnameMaxLen = 255, - hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z-]{0,62}$/, - hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z-]{0,62})(.*)$/, + hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/, + hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/, // protocols that can allow "unsafe" and "unwise" chars. unsafeProtocol = { 'javascript': true, diff --git a/test/simple/test-url.js b/test/simple/test-url.js index ea85bc967fe..8cee8eb2794 100644 --- a/test/simple/test-url.js +++ b/test/simple/test-url.js @@ -274,8 +274,17 @@ var parseTests = { 'search' : '?search=foo', 'query' : 'search=foo', 'hash' : '#bar' + }, + 'http://bucket_name.s3.amazonaws.com/image.jpg': { + protocol: 'http:', + slashes: true, + host: 'bucket_name.s3.amazonaws.com', + hostname: 'bucket_name.s3.amazonaws.com', + pathname: '/image.jpg', + href: 'http://bucket_name.s3.amazonaws.com/image.jpg' } }; + for (var u in parseTests) { var actual = url.parse(u), expected = parseTests[u]; |