Skip to content

Commit

Permalink
emoji: Replace escape_regexp with _.escapeRegExp.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk authored and timabbott committed Jul 29, 2020
1 parent 8cc34d1 commit 8e79e0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions static/js/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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",
);
}
Expand Down
10 changes: 3 additions & 7 deletions static/shared/js/emoji.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import _ from "lodash";

// We will get actual values when we get initialized.
let emoji_codes = {};

Expand All @@ -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() {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8e79e0e

Please sign in to comment.