Skip to content

Commit

Permalink
url: fast path ascii domains, do not run ToASCII
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zimbabao committed May 15, 2017
1 parent 35e901d commit a13c377
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
27 changes: 0 additions & 27 deletions test/fixtures/url-domains-with-hyphens.js

This file was deleted.

15 changes: 10 additions & 5 deletions test/parallel/test-whatwg-url-domainto.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { domainToASCII, domainToUnicode } = require('url');

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

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

{
for (const [i, { ascii, unicode }] of testsHyphenDomains.valid.entries()) {
assert.strictEqual(ascii, domainToASCII(unicode),
`domainToASCII(${i + 1})`);
}
[
'r4---sn-a5mlrn7s.gevideo.com',
'-sn-a5mlrn7s.gevideo.com',
'sn-a5mlrn7s-.gevideo.com',
'-sn-a5mlrn7s-.gevideo.com',
'-sn--a5mlrn7s-.gevideo.com'
].forEach((domain) => {
assert.strictEqual(domain, domainToASCII(domain),
`domainToASCII(${domain})`);
})
}

{
Expand Down

0 comments on commit a13c377

Please sign in to comment.