Encode 2028 & 2029 chars in text form, close #7

This commit is contained in:
Vitaly Puzrin
2020-05-18 08:02:04 +03:00
parent 193738762a
commit 9d6bc548cd
4 changed files with 14 additions and 3 deletions

View File

@@ -3,6 +3,7 @@
- Update mapping data to version 13.0.0
http://www.unicode.org/Public/security/latest/confusables.txt
- Encode `\u2028` & `\u2029` as text, #7.
1.0.5 / 2020-03-03

View File

@@ -157,8 +157,8 @@
"໊": "๊",
"໋": "๋",
"꙯": "⃩",
"": " ",
"": " ",
"\u2028": " ",
"\u2029": " ",
"": " ",
" ": " ",
"": " ",

View File

@@ -26,4 +26,8 @@ describe('unhomoglyph', function () {
assert.strictEqual(unhomoglyph('1abcаа'), 'labcaa');
});
it('2028 & 2029 should be ok after replace in updater', function () {
assert.strictEqual(data['\u2028'], ' ');
assert.strictEqual(data['\u2029'], ' ');
});
});

View File

@@ -37,8 +37,14 @@ function save(str) {
result[src] = dst;
});
let output = JSON.stringify(result, null, ' ')
// Workaround for ES9 <=> ES10 inconsistency
// https://github.com/nodeca/unhomoglyph/issues/7
// https://github.com/facebook/hermes/issues/235#issuecomment-623606572
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
fs.writeFileSync(SAVE_PATH, JSON.stringify(result, null, ' '));
fs.writeFileSync(SAVE_PATH, output);
console.log('Done!');
}