From 9e3c08db40b8916968b9f30096c7be3f00ce9647 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:44:51 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/chat/protocols/matrix/lib/unhomoglyph/index.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 comm/chat/protocols/matrix/lib/unhomoglyph/index.js (limited to 'comm/chat/protocols/matrix/lib/unhomoglyph/index.js') diff --git a/comm/chat/protocols/matrix/lib/unhomoglyph/index.js b/comm/chat/protocols/matrix/lib/unhomoglyph/index.js new file mode 100644 index 0000000000..39150ea2ed --- /dev/null +++ b/comm/chat/protocols/matrix/lib/unhomoglyph/index.js @@ -0,0 +1,20 @@ +'use strict'; + + +var data = require('./data.json'); + +function escapeRegexp(str) { + return str.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'); +} + +var REPLACE_RE = RegExp(Object.keys(data).map(escapeRegexp).join('|'), 'g'); + +function replace_fn(match) { + return data[match]; +} + +function unhomoglyph(str) { + return str.replace(REPLACE_RE, replace_fn); +} + +module.exports = unhomoglyph; -- cgit v1.2.3