From 0df144cb622f2fe69e7b0ab975c7046d2d3e931d Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 11 Jul 2017 18:27:35 +0100 Subject: [PATCH] Update `unicodeToImage` to maintain compatibility with emojione We recently updated our version of emojione but this update included the addition of emoji represented in unicode with ZWJ (Zero-Width-Joiners). These ZWJs are not present in the asset file names, so any emoji with ZWJ in them were just not found (404 on the web client). This updates `unicodeToImage` to be compatible with emojione 2.2.7 so that the correct filenames are used when converting from unicode to . --- src/HtmlUtils.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 9041e88594..20b444b8da 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -38,7 +38,7 @@ const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/; * because we want to include emoji shortnames in title text */ export function unicodeToImage(str) { - let replaceWith, unicode, alt; + let replaceWith, unicode, alt, short, fname; const mappedUnicode = emojione.mapUnicodeToShort(); str = str.replace(emojione.regUnicode, function(unicodeChar) { @@ -50,11 +50,14 @@ export function unicodeToImage(str) { // get the unicode codepoint from the actual char unicode = emojione.jsEscapeMap[unicodeChar]; + short = mappedUnicode[unicode]; + fname = emojione.emojioneList[short].fname; + // depending on the settings, we'll either add the native unicode as the alt tag, otherwise the shortname alt = (emojione.unicodeAlt) ? emojione.convert(unicode.toUpperCase()) : mappedUnicode[unicode]; const title = mappedUnicode[unicode]; - replaceWith = `${alt}`; + replaceWith = `${alt}`; return replaceWith; } });