Skip to content

Commit a13c377

Browse files
committed
url: fast path ascii domains, do not run ToASCII
To match browser behavior fast path ascii only domains and do not run ToASCII on them. Fixes: nodejs#12965 Refs: nodejs#12966 Refs: whatwg/url#309
1 parent 35e901d commit a13c377

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

test/fixtures/url-domains-with-hyphens.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/parallel/test-whatwg-url-domainto.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const { domainToASCII, domainToUnicode } = require('url');
1111

1212
// Tests below are not from WPT.
1313
const tests = require('../fixtures/url-idna.js');
14-
const testsHyphenDomains = require('../fixtures/url-domains-with-hyphens.js');
1514

1615
{
1716
const expectedError = common.expectsError(
@@ -36,10 +35,16 @@ const testsHyphenDomains = require('../fixtures/url-domains-with-hyphens.js');
3635
}
3736

3837
{
39-
for (const [i, { ascii, unicode }] of testsHyphenDomains.valid.entries()) {
40-
assert.strictEqual(ascii, domainToASCII(unicode),
41-
`domainToASCII(${i + 1})`);
42-
}
38+
[
39+
'r4---sn-a5mlrn7s.gevideo.com',
40+
'-sn-a5mlrn7s.gevideo.com',
41+
'sn-a5mlrn7s-.gevideo.com',
42+
'-sn-a5mlrn7s-.gevideo.com',
43+
'-sn--a5mlrn7s-.gevideo.com'
44+
].forEach((domain) => {
45+
assert.strictEqual(domain, domainToASCII(domain),
46+
`domainToASCII(${domain})`);
47+
})
4348
}
4449

4550
{

0 commit comments

Comments
 (0)