summaryrefslogtreecommitdiff
path: root/test/parallel/test-icu-punycode.js
diff options
context:
space:
mode:
authorRajaram Gaunker <zimbabao@gmail.com>2017-05-11 00:19:15 -0700
committerTimothy Gu <timothygu99@gmail.com>2017-05-20 00:36:57 -0700
commit06a617aa21c434b5e607370e7ee0051d506a4793 (patch)
tree512f0e7f3d7e5573675b93f7b4d322d7030f4c5b /test/parallel/test-icu-punycode.js
parent841bb4c61f07a5c2bf818a3b985ea0f88257210e (diff)
downloadandroid-node-v8-06a617aa21c434b5e607370e7ee0051d506a4793.tar.gz
android-node-v8-06a617aa21c434b5e607370e7ee0051d506a4793.tar.bz2
android-node-v8-06a617aa21c434b5e607370e7ee0051d506a4793.zip
url: update IDNA error conditions
This commit contains three separate changes: - Always return a string from ToUnicode no matter if an error occurred. - Disable CheckHyphens boolean flag. This flag will soon be enabled in the URL Standard, but is implemented manually by selectively ignoring certain errors. - Enable CheckBidi boolean flag per URL Standard update. This allows domain names with hyphens at 3 and 4th position, as well as those with leading and trailing hyphens. They are technically invalid, but seen in the wild. Tests are updated and simplified accordingly. PR-URL: https://github.com/nodejs/node/pull/12966 Fixes: https://github.com/nodejs/node/issues/12965 Refs: https://github.com/whatwg/url/pull/309 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'test/parallel/test-icu-punycode.js')
-rw-r--r--test/parallel/test-icu-punycode.js22
1 files changed, 8 insertions, 14 deletions
diff --git a/test/parallel/test-icu-punycode.js b/test/parallel/test-icu-punycode.js
index 411704bb8f..ba2014bdc8 100644
--- a/test/parallel/test-icu-punycode.js
+++ b/test/parallel/test-icu-punycode.js
@@ -23,19 +23,13 @@ const tests = require('../fixtures/url-idna.js');
}
{
- const errorRe = {
- ascii: /^Error: Cannot convert name to ASCII$/,
- unicode: /^Error: Cannot convert name to Unicode$/
- };
- const convertFunc = {
- ascii: icu.toASCII,
- unicode: icu.toUnicode
- };
-
- for (const [i, { url, mode }] of tests.invalid.entries()) {
- assert.throws(() => convertFunc[mode](url), errorRe[mode],
- `Invalid case ${i + 1}`);
- assert.doesNotThrow(() => convertFunc[mode](url, true),
- `Invalid case ${i + 1} in lenient mode`);
+ for (const [i, url] of tests.invalid.entries()) {
+ assert.throws(() => icu.toASCII(url),
+ /^Error: Cannot convert name to ASCII$/,
+ `ToASCII invalid case ${i + 1}`);
+ assert.doesNotThrow(() => icu.toASCII(url, true),
+ `ToASCII invalid case ${i + 1} in lenient mode`);
+ assert.doesNotThrow(() => icu.toUnicode(url),
+ `ToUnicode invalid case ${i + 1}`);
}
}