From 497be91c4dfeb3a122e5cf6742a7555cb45eee05 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 19 May 2019 17:53:36 +0100 Subject: [PATCH] combine regexps correctly --- src/HtmlUtils.js | 2 +- src/autocomplete/EmojiProvider.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 8fae992268..68a83bfd35 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -50,7 +50,7 @@ const ZWJ_REGEX = new RegExp("\u200D|\u2003", "g"); // Regex pattern for whitespace characters const WHITESPACE_REGEX = new RegExp("\\s", "g"); -const BIGEMOJI_REGEX = new RegExp(`^(${EMOJIBASE_REGEX})+$`, "i"); +const BIGEMOJI_REGEX = new RegExp(`^(${EMOJIBASE_REGEX.source})+$`, 'i'); const COLOR_REGEX = /^#[0-9a-fA-F]{6}$/; diff --git a/src/autocomplete/EmojiProvider.js b/src/autocomplete/EmojiProvider.js index 95654e403d..c90343ca18 100644 --- a/src/autocomplete/EmojiProvider.js +++ b/src/autocomplete/EmojiProvider.js @@ -51,11 +51,11 @@ const CATEGORY_ORDER = [ // (^|\s|(emojiUnicode)) to make sure we're either at the start of the string or there's a // whitespace character or an emoji before the emoji. The reason for unicodeRegexp is // that we need to support inputting multiple emoji with no space between them. -const EMOJI_REGEX = new RegExp('(?:^|\\s|' + UNICODE_REGEX + ')(' + EMOTICON_REGEX + '|:[+-\\w]*:?)$', 'g'); +const EMOJI_REGEX = new RegExp('(?:^|\\s|' + UNICODE_REGEX.source + ')(' + EMOTICON_REGEX.source + '|:[+-\\w]*:?)$', 'g'); // We also need to match the non-zero-length prefixes to remove them from the final match, // and update the range so that we don't replace the whitespace or the previous emoji. -const MATCH_PREFIX_REGEX = new RegExp('(\\s|' + UNICODE_REGEX + ')'); +const MATCH_PREFIX_REGEX = new RegExp('(\\s|' + UNICODE_REGEX.source + ')'); const EMOJI_SHORTNAMES = Object.keys(EmojiData).map((key) => EmojiData[key]).sort( (a, b) => {