Browse Source

Close #1360 url: Allow _ in hostnames.

v0.7.4-release
isaacs 14 years ago
parent
commit
ddfc6b78cc
  1. 4
      lib/url.js
  2. 9
      test/simple/test-url.js

4
lib/url.js

@ -44,8 +44,8 @@ var protocolPattern = /^([a-z0-9]+:)/i,
.concat(unwise).concat(autoEscape), .concat(unwise).concat(autoEscape),
nonAuthChars = ['/', '@', '?', '#'].concat(delims), nonAuthChars = ['/', '@', '?', '#'].concat(delims),
hostnameMaxLen = 255, hostnameMaxLen = 255,
hostnamePartPattern = /^[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})(.*)$/, hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,
// protocols that can allow "unsafe" and "unwise" chars. // protocols that can allow "unsafe" and "unwise" chars.
unsafeProtocol = { unsafeProtocol = {
'javascript': true, 'javascript': true,

9
test/simple/test-url.js

@ -274,8 +274,17 @@ var parseTests = {
'search' : '?search=foo', 'search' : '?search=foo',
'query' : 'search=foo', 'query' : 'search=foo',
'hash' : '#bar' '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) { for (var u in parseTests) {
var actual = url.parse(u), var actual = url.parse(u),
expected = parseTests[u]; expected = parseTests[u];

Loading…
Cancel
Save