From 9e1cf71bc397444654302c61ad9f777a8e2a38c7 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 31 May 2016 16:10:12 -0400 Subject: Fixed emoticons consuming the preceeding whitespace (#3187) --- webapp/utils/emoticons.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/utils/emoticons.jsx b/webapp/utils/emoticons.jsx index 35c7dba04..58057a187 100644 --- a/webapp/utils/emoticons.jsx +++ b/webapp/utils/emoticons.jsx @@ -132,7 +132,7 @@ export function getEmoticonsByCodePoint() { export function handleEmoticons(text, tokens) { let output = text; - function replaceEmoticonWithToken(fullMatch, matchText, name) { + function replaceEmoticonWithToken(fullMatch, prefix, matchText, name) { if (getEmoticonsByName().has(name)) { const index = tokens.size; const alias = `MM_EMOTICON${index}`; @@ -143,14 +143,14 @@ export function handleEmoticons(text, tokens) { originalText: fullMatch }); - return alias; + return prefix + alias; } return fullMatch; } // match named emoticons like :goat: - output = output.replace(/(:([a-zA-Z0-9_-]+):)/g, (fullMatch, matchText, name) => replaceEmoticonWithToken(fullMatch, matchText, name)); + output = output.replace(/(:([a-zA-Z0-9_-]+):)/g, (fullMatch, matchText, name) => replaceEmoticonWithToken(fullMatch, '', matchText, name)); // match text smilies like :D for (const name of Object.keys(emoticonPatterns)) { @@ -158,7 +158,7 @@ export function handleEmoticons(text, tokens) { // this might look a bit funny, but since the name isn't contained in the actual match // like with the named emoticons, we need to add it in manually - output = output.replace(pattern, (fullMatch, matchText) => replaceEmoticonWithToken(fullMatch, matchText, name)); + output = output.replace(pattern, (fullMatch, prefix, matchText) => replaceEmoticonWithToken(fullMatch, prefix, matchText, name)); } return output; -- cgit v1.2.3-1-g7c22