From 7a6ebf37cc4a4798b43eccb49c835a5c624b2356 Mon Sep 17 00:00:00 2001 From: Paul Procopiou <1726774+pauldps@users.noreply.github.com> Date: Fri, 3 May 2024 13:33:40 -0400 Subject: [PATCH] `wrapEmoji` should ignore all non-unicode (#41) --- src/constants.js | 2 +- test/wrapEmoji.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/constants.js b/src/constants.js index e3e7a33..2d05133 100644 --- a/src/constants.js +++ b/src/constants.js @@ -28,7 +28,7 @@ export const STRIP_RX = new RegExp('{(?:' + COLORS + '|/)}', 'gim') /** * RegExp to wrap all emoji in tags. */ -export const EMOJI_RX = /([\p{Emoji}\p{Emoji_Presentation}]+)/gimsu +export const EMOJI_RX = /([\p{Emoji_Presentation}]+)/gu /** * Template to use when replacing emoji. diff --git a/test/wrapEmoji.js b/test/wrapEmoji.js index db142a3..2873367 100644 --- a/test/wrapEmoji.js +++ b/test/wrapEmoji.js @@ -11,7 +11,7 @@ describe('#wrapEmoji', function () { }) it('does not affect non-emoji', function () { - expect(wrapEmoji('abcπŸ˜…def')).to.eq('abcπŸ˜…def') + expect(wrapEmoji('123abcπŸ˜…def456#*')).to.eq('123abcπŸ˜…def456#*') }) it('tags all emojis', function () { @@ -25,4 +25,8 @@ describe('#wrapEmoji', function () { it('tags sequential emojis in a single tag', function () { expect(wrapEmoji('abc πŸ˜‚πŸ’―πŸ˜… def')).to.eq('abc πŸ˜‚πŸ’―πŸ˜… def') }) + + it('breaks down sequential emojis split by multiline', function () { + expect(wrapEmoji('abc πŸ˜‚\nπŸ’―πŸ˜… def')).to.eq('abc πŸ˜‚\nπŸ’―πŸ˜… def') + }) })