Skip to content

Commit ddfc6b7

Browse files
committed
Close #1360 url: Allow _ in hostnames.
1 parent 973153d commit ddfc6b7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/url.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ var protocolPattern = /^([a-z0-9]+:)/i,
4444
.concat(unwise).concat(autoEscape),
4545
nonAuthChars = ['/', '@', '?', '#'].concat(delims),
4646
hostnameMaxLen = 255,
47-
hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z-]{0,62}$/,
48-
hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z-]{0,62})(.*)$/,
47+
hostnamePartPattern = /^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,
48+
hostnamePartStart = /^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,
4949
// protocols that can allow "unsafe" and "unwise" chars.
5050
unsafeProtocol = {
5151
'javascript': true,

test/simple/test-url.js

+9
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,17 @@ var parseTests = {
274274
'search' : '?search=foo',
275275
'query' : 'search=foo',
276276
'hash' : '#bar'
277+
},
278+
'http://bucket_name.s3.amazonaws.com/image.jpg': {
279+
protocol: 'http:',
280+
slashes: true,
281+
host: 'bucket_name.s3.amazonaws.com',
282+
hostname: 'bucket_name.s3.amazonaws.com',
283+
pathname: '/image.jpg',
284+
href: 'http://bucket_name.s3.amazonaws.com/image.jpg'
277285
}
278286
};
287+
279288
for (var u in parseTests) {
280289
var actual = url.parse(u),
281290
expected = parseTests[u];

0 commit comments

Comments
 (0)