Files
node/test/parallel/test-url-domain-ascii-unicode.js
Antoine du Hamel ef6b8cc3c3 test: ensure assertions are reached on more tests
PR-URL: https://github.com/nodejs/node/pull/60728
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2025-11-17 17:10:24 +00:00

28 lines
969 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 assert = 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);
assert.strictEqual(domainConvertedToASCII, ascii);
const asciiConvertedToUnicode = domainToUnicode(ascii);
assert.strictEqual(asciiConvertedToUnicode, domain);
}
});