emoji: Replace escape_regexp with _.escapeRegExp.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-29 12:20:41 -07:00 committed by Tim Abbott
parent 8cc34d168e
commit 8e79e0e63b
2 changed files with 5 additions and 9 deletions

View File

@ -13,7 +13,7 @@ function zephyr_stream_name_match(message, operand) {
base_stream_name = m[1];
}
const related_regexp = new RegExp(
/^(un)*/.source + util.escape_regexp(base_stream_name) + /(\.d)*$/.source,
/^(un)*/.source + _.escapeRegExp(base_stream_name) + /(\.d)*$/.source,
"i",
);
return related_regexp.test(message.stream);
@ -37,7 +37,7 @@ function zephyr_topic_name_match(message, operand) {
related_regexp = /^(|personal|\(instance ""\))(\.d)*$/i;
} else {
related_regexp = new RegExp(
/^/.source + util.escape_regexp(base_topic) + /(\.d)*$/.source,
/^/.source + _.escapeRegExp(base_topic) + /(\.d)*$/.source,
"i",
);
}

View File

@ -1,3 +1,5 @@
import _ from "lodash";
// We will get actual values when we get initialized.
let emoji_codes = {};
@ -23,12 +25,6 @@ export function get_server_realm_emoji_data() {
return server_realm_emoji_data;
}
function escape_regexp(string) {
// HIGHLY DEPRECATED!!!!
// We should fix this in our upcoming lodash sweep.
return string.replace(/([.*+?^=!:${}()|[\]/\\])/g, "\\$1");
}
let emoticon_translations = [];
function build_emoticon_translations() {
@ -57,7 +53,7 @@ function build_emoticon_translations() {
const translations = [];
for (const [emoticon, replacement_text] of Object.entries(emoji_codes.emoticon_conversions)) {
const regex = new RegExp("(" + escape_regexp(emoticon) + ")", "g");
const regex = new RegExp("(" + _.escapeRegExp(emoticon) + ")", "g");
translations.push({
regex,