From e585b227f1152be6d60311422579a4f1b66f1876 Mon Sep 17 00:00:00 2001 From: Fayaz Ahmed <15716057+fayazara@users.noreply.github.com> Date: Wed, 14 Sep 2022 19:45:04 +0530 Subject: [PATCH] chore: Check for empty strings in name formatter (#5434) --- app/javascript/shared/helpers/emoji.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/javascript/shared/helpers/emoji.js b/app/javascript/shared/helpers/emoji.js index 371472623..5323a14ce 100644 --- a/app/javascript/shared/helpers/emoji.js +++ b/app/javascript/shared/helpers/emoji.js @@ -34,11 +34,14 @@ export const hasEmojiSupport = () => { }; export const removeEmoji = text => { - return text - .replace( - /([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, - '' - ) - .replace(/\s+/g, ' ') - .trim(); + if (text) { + return text + .replace( + /([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, + '' + ) + .replace(/\s+/g, ' ') + .trim(); + } + return ''; };