From a2bd1819110bb40db0f4c88de2888426d2afd7d7 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Mon, 21 Dec 2020 04:32:39 +0200 Subject: [PATCH] Removed unnecessary ampersand replacement --- qml/js/twemoji.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/qml/js/twemoji.js b/qml/js/twemoji.js index 054bb37..3806570 100644 --- a/qml/js/twemoji.js +++ b/qml/js/twemoji.js @@ -16,8 +16,7 @@ var re = /(?:\ud83d\udc68\ud83c\udffb\u200d\ud83e\udd1d\u200d\ud83d\udc68\ud83c[ // avoid using a string literal like '\u200D' here because minifiers expand it inline U200D = String.fromCharCode(0x200D), - basePath = Qt.resolvedUrl("./emoji/"), - ampersandRe = /\&(?!amp;)/g; + basePath = Qt.resolvedUrl("./emoji/"); function toCodePoint(unicodeSurrogates) { var @@ -41,15 +40,13 @@ function toCodePoint(unicodeSurrogates) { function emojify(str, emojiSize) { return String(str).replace(re, function (rawText) { - var ret = rawText, - iconId = toCodePoint(rawText.indexOf(U200D) < 0 ? + var iconId = toCodePoint(rawText.indexOf(U200D) < 0 ? rawText.replace(UFE0Fg, '') : - rawText - ); - if (iconId) { + rawText); + return iconId ? // recycle the match string replacing the emoji // with its image counter part - ret = '' - ); + ) : rawText; } - return ret.replace(ampersandRe, "&"); - }); + ); }