From 1a8be5444c32d04067e42fdeca6d2abc91b718ff Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 10 Jan 2019 06:33:45 -0300 Subject: [PATCH] MM-13666 Detect post as emoji only if not a codeblock (#2497) * Detect post as emoji only if not a codeblock * Feedback review Co-Authored-By: enahum * Feedback review Co-Authored-By: enahum --- app/utils/emoji_utils.js | 2 +- app/utils/emoji_utils.test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/utils/emoji_utils.js b/app/utils/emoji_utils.js index ec652a9082..6fca19b40b 100644 --- a/app/utils/emoji_utils.js +++ b/app/utils/emoji_utils.js @@ -46,7 +46,7 @@ function isEmoticon(text) { } export function hasEmojisOnly(message, customEmojis) { - if (!message || message.length === 0) { + if (!message || message.length === 0 || (/^\s{4}/).test(message)) { return {isEmojiOnly: false, shouldRenderJumboEmoji: false}; } diff --git a/app/utils/emoji_utils.test.js b/app/utils/emoji_utils.test.js index d76765036b..dce68d3c1b 100644 --- a/app/utils/emoji_utils.test.js +++ b/app/utils/emoji_utils.test.js @@ -60,6 +60,10 @@ describe('hasEmojisOnly with named emojis', () => { name: 'Mixed valid and invalid named emojis', message: ' :smile: invalid :heart: ', expected: {isEmojiOnly: false, shouldRenderJumboEmoji: false}, + }, { + name: 'This should render a codeblock instead', + message: ' :D', + expected: {isEmojiOnly: false, shouldRenderJumboEmoji: false}, }]; const customEmojis = new Map([['valid_custom', 0]]);