From 4aef70f15b1efa354201a755e5f2f91c6117c74f Mon Sep 17 00:00:00 2001 From: swarnendusahu10-dotcom Date: Sat, 24 Oct 2026 00:56:48 +0530 Subject: [PATCH] fix: convert all emoji shortnames in message text --- packages/react/src/lib/emoji.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/react/src/lib/emoji.js b/packages/react/src/lib/emoji.js index d438099c70..3c861fd6ba 100644 --- a/packages/react/src/lib/emoji.js +++ b/packages/react/src/lib/emoji.js @@ -1,12 +1,12 @@ import emojione from 'emoji-toolkit'; export const parseEmoji = (text) => { - const regx = /:([^:]*):/g; - const regx_data = text.match(regx); - if (regx_data) { - const result = regx_data[regx_data.length - 1]; - const d = emojione.shortnameToUnicode(result); - if (d !== undefined) text = text.replace(result, d); + if (!text || typeof text !== 'string') { + return text; } - return text; + const regx = /:([^:\s]+):/g; + return text.replace(regx, (match) => { + const unicode = emojione.shortnameToUnicode(match); + return unicode !== undefined ? unicode : match; + }); };