diff --git a/CHANGELOG.md b/CHANGELOG.md index 561d0b3..27bd0fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/data.json b/data.json index 7eb4d14..209962e 100644 --- a/data.json +++ b/data.json @@ -157,8 +157,8 @@ "໊": "๊", "໋": "๋", "꙯": "⃩", - "
": " ", - "
": " ", + "\u2028": " ", + "\u2029": " ", " ": " ", " ": " ", " ": " ", diff --git a/test.js b/test.js index a56bdb8..c83a13c 100644 --- a/test.js +++ b/test.js @@ -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'], ' '); + }); }); diff --git a/update.js b/update.js index 0646e2f..5340c4b 100644 --- a/update.js +++ b/update.js @@ -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!'); }