Skip to content

Commit

Permalink
Close #1360 url: Allow _ in hostnames.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jul 19, 2011
1 parent 973153d commit ddfc6b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions test/simple/test-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit ddfc6b7

Please sign in to comment.