mirror of
https://github.com/litruv/unhomoglyph.git
synced 2026-07-25 03:06:12 +10:00
Encode 2028 & 2029 chars in text form, close #7
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
- Update mapping data to version 13.0.0
|
- Update mapping data to version 13.0.0
|
||||||
http://www.unicode.org/Public/security/latest/confusables.txt
|
http://www.unicode.org/Public/security/latest/confusables.txt
|
||||||
|
- Encode `\u2028` & `\u2029` as text, #7.
|
||||||
|
|
||||||
|
|
||||||
1.0.5 / 2020-03-03
|
1.0.5 / 2020-03-03
|
||||||
|
|||||||
@@ -157,8 +157,8 @@
|
|||||||
"໊": "๊",
|
"໊": "๊",
|
||||||
"໋": "๋",
|
"໋": "๋",
|
||||||
"꙯": "⃩",
|
"꙯": "⃩",
|
||||||
"
": " ",
|
"\u2028": " ",
|
||||||
"
": " ",
|
"\u2029": " ",
|
||||||
" ": " ",
|
" ": " ",
|
||||||
" ": " ",
|
" ": " ",
|
||||||
" ": " ",
|
" ": " ",
|
||||||
|
|||||||
4
test.js
4
test.js
@@ -26,4 +26,8 @@ describe('unhomoglyph', function () {
|
|||||||
assert.strictEqual(unhomoglyph('1abcаа'), 'labcaa');
|
assert.strictEqual(unhomoglyph('1abcаа'), 'labcaa');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('2028 & 2029 should be ok after replace in updater', function () {
|
||||||
|
assert.strictEqual(data['\u2028'], ' ');
|
||||||
|
assert.strictEqual(data['\u2029'], ' ');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,8 +37,14 @@ function save(str) {
|
|||||||
result[src] = dst;
|
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!');
|
console.log('Done!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user