0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-url-domain-ascii-unicode.js
Yagiz Nizipli 59220bb08a
test: move more url tests to node:test
PR-URL: https://github.com/nodejs/node/pull/54636
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2024-09-13 00:29:55 +00:00

28 lines
964 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const { hasIntl } = require('../common');
const { strictEqual } = require('node:assert');
const { domainToASCII, domainToUnicode } = require('node:url');
const { test } = require('node:test');
const domainWithASCII = [
['ıíd', 'xn--d-iga7r'],
['يٴ', 'xn--mhb8f'],
['www.ϧƽəʐ.com', 'www.xn--cja62apfr6c.com'],
['новини.com', 'xn--b1amarcd.com'],
['名がドメイン.com', 'xn--v8jxj3d1dzdz08w.com'],
['افغانستا.icom.museum', 'xn--mgbaal8b0b9b2b.icom.museum'],
['الجزائر.icom.fake', 'xn--lgbbat1ad8j.icom.fake'],
['भारत.org', 'xn--h2brj9c.org'],
];
test('domainToASCII and domainToUnicode', { skip: !hasIntl }, () => {
for (const [domain, ascii] of domainWithASCII) {
const domainConvertedToASCII = domainToASCII(domain);
strictEqual(domainConvertedToASCII, ascii);
const asciiConvertedToUnicode = domainToUnicode(ascii);
strictEqual(asciiConvertedToUnicode, domain);
}
});