Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

emoji: Replace escape_regexp with _.escapeRegExp.

Anders Kaseorg8e79e0e63b77
diff --git a/static/js/filter.js b/static/js/filter.js
index d9768c8380f..56e1ed4fea9 100644
--- a/static/js/filter.js
+++ b/static/js/filter.js
@@ -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",
);
}
diff --git a/static/shared/js/emoji.js b/static/shared/js/emoji.js
index 6d9f9bc75c9..e4441b830f4 100644
--- a/static/shared/js/emoji.js
+++ b/static/shared/js/emoji.js
@@ -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,