From 44ff83ef173ee98180e130dfdeedcce4070791b3 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 30 Mar 2019 20:55:49 +0000 Subject: [PATCH] Consider spacing when converting string to unicode emote --- webapp/titanembeds/static/js/embed.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index f764f2e..9d804d5 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -1878,8 +1878,9 @@ }; for (var i in map) { var escaped = i.replace(/([()[{*+.$^\\|?])/g, '\\$1'); + escaped = "(\\s|^)(" + escaped + ")(\\s|$)"; var regex = new RegExp(escaped, 'gim'); - input = input.replace(regex, map[i]); + input = input.replace(regex, "$1" + map[i] + "$3"); } return input; }