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 refactor: Avoid util dep with minor hack.

Steve Howella028aa5f8a0a
diff --git a/static/js/emoji.js b/static/js/emoji.js
index 7c94c12dd09..735ae44a6f3 100644
--- a/static/js/emoji.js
+++ b/static/js/emoji.js
@@ -1,5 +1,3 @@
-const util = require("./util");
-
// We will get actual values when we get initialized.
let emoji_codes = {};
@@ -23,6 +21,12 @@ let server_realm_emoji_data = {};
// We really want to deprecate this, too.
exports.get_server_realm_emoji_data = () => 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() {
@@ -51,7 +55,7 @@ function build_emoticon_translations() {
const translations = [];
for (const [emoticon, replacement_text] of Object.entries(emoji_codes.emoticon_conversions)) {
- const regex = new RegExp("(" + util.escape_regexp(emoticon) + ")", "g");
+ const regex = new RegExp("(" + escape_regexp(emoticon) + ")", "g");
translations.push({
regex,