Skip to content

Commit 7144f81

Browse files
darylthayilporchFishrock123
authored andcommitted
test: add test for url module domainToAscii and domainToUnicode
PR-URL: #10031 Reviewed-By: James M Snell <[email protected]>
1 parent 2f6d0c7 commit 7144f81

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
require('../common');
4+
const strictEqual = require('assert').strictEqual;
5+
const url = require('url');
6+
7+
const domainToASCII = url.URL.domainToASCII;
8+
const domainToUnicode = url.URL.domainToUnicode;
9+
10+
const domainWithASCII = [
11+
['ıídيٴ', 'xn--d-iga7ro0q9f'],
12+
['www.ϧƽəʐ.com', 'www.xn--cja62apfr6c.com'],
13+
['новини.com', 'xn--b1amarcd.com'],
14+
['名がドメイン.com', 'xn--v8jxj3d1dzdz08w.com'],
15+
['افغانستا.icom.museum', 'xn--mgbaal8b0b9b2b.icom.museum'],
16+
['الجزائر.icom.fake', 'xn--lgbbat1ad8j.icom.fake'],
17+
['भारत.org', 'xn--h2brj9c.org']
18+
];
19+
20+
domainWithASCII.forEach((pair) => {
21+
const domain = pair[0];
22+
const ascii = pair[1];
23+
const domainConvertedToASCII = domainToASCII(domain);
24+
strictEqual(domainConvertedToASCII, ascii);
25+
const asciiConvertedToUnicode = domainToUnicode(ascii);
26+
strictEqual(asciiConvertedToUnicode, domain);
27+
});

0 commit comments

Comments
 (0)