Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrapEmoji should ignore all non-unicode #41

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const STRIP_RX = new RegExp('{(?:' + COLORS + '|/)}', 'gim')
/**
* RegExp to wrap all emoji in <span> 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.
Expand Down
6 changes: 5 additions & 1 deletion test/wrapEmoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('#wrapEmoji', function () {
})

it('does not affect non-emoji', function () {
expect(wrapEmoji('abc😅def')).to.eq('abc<span class="wmE">😅</span>def')
expect(wrapEmoji('123abc😅def456#*')).to.eq('123abc<span class="wmE">😅</span>def456#*')
})

it('tags all emojis', function () {
Expand All @@ -25,4 +25,8 @@ describe('#wrapEmoji', function () {
it('tags sequential emojis in a single tag', function () {
expect(wrapEmoji('abc 😂💯😅 def')).to.eq('abc <span class="wmE">😂💯😅</span> def')
})

it('breaks down sequential emojis split by multiline', function () {
expect(wrapEmoji('abc 😂\n💯😅 def')).to.eq('abc <span class="wmE">😂</span>\n<span class="wmE">💯😅</span> def')
})
})
Loading