From d9a6a1faff33680485995a9c5a2c12f231d9dec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9Frul=20Topuz?= Date: Sat, 18 Apr 2020 15:06:21 +0300 Subject: [PATCH 1/2] case-insensitive test --- tests/tests.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/tests.js b/tests/tests.js index ced85a0..24fef56 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -190,6 +190,14 @@ const testData = { 'decoded': 'caf\xE9.com', 'encoded': 'xn--caf-dma.com' }, + { + 'decoded': 'ÜBER.COM', + 'encoded': 'xn--BER-ska.COM' + }, + { + 'decoded': 'sPhÈRè.com', + 'encoded': 'xn--sPhR-nka7q.com' + }, { 'decoded': '\u2603-\u2318.com', 'encoded': 'xn----dqo34k.com' From 967ac02c3c740725ddea7aa0fa319b1467f48b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9Frul=20Topuz?= Date: Sat, 18 Apr 2020 15:06:58 +0300 Subject: [PATCH 2/2] do not touch case-insensitive --- punycode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/punycode.js b/punycode.js index 752b98a..ac9d577 100644 --- a/punycode.js +++ b/punycode.js @@ -14,7 +14,7 @@ const initialN = 128; // 0x80 const delimiter = '-'; // '\x2D' /** Regular expressions */ -const regexPunycode = /^xn--/; +const regexPunycode = /^xn--/i; const regexNonASCII = /[^\0-\x7F]/; // Note: U+007F DEL is excluded too. const regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators @@ -389,7 +389,7 @@ const encode = function(input) { const toUnicode = function(input) { return mapDomain(input, function(string) { return regexPunycode.test(string) - ? decode(string.slice(4).toLowerCase()) + ? decode(string.slice(4)) : string; }); };