Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/replace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ describe('replace', () => {
it('ignores known existing complex emojis', () => {
expect(replace('Some 🍕❤️‍💋‍☕ emoji', '')).toBe('Some ❤️‍💋‍☕ emoji')
})

it('replaces an emoji that has a skin tone modifier', () => {
expect(replace('👍🏽', () => 'Z')).toBe('Z')
expect(replace('thumbs 👍🏽 up', '')).toBe('thumbs up')
})
})
3 changes: 2 additions & 1 deletion src/replace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { assert } from '@sindresorhus/is'
import skinTone from 'skin-tone'

import { Emoji } from './data.js'
import { findByCode } from './findByCode.js'
Expand Down Expand Up @@ -31,7 +32,7 @@ export const replace = (

return characters
.map((character, index) => {
const found = findByCode(character)
const found = findByCode(skinTone(character, 'none'))
if (!found) {
return character
}
Expand Down
5 changes: 5 additions & 0 deletions src/strip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ describe('strip', () => {
it('preserves spaces around emoji when preserveSpaces is true', () => {
expect(strip('a ☕ c', { preserveSpaces: true })).toBe('a c')
})

it('removes an emoji that has a skin tone modifier', () => {
expect(strip('X👍🏽Y')).toBe('XY')
expect(strip('a👋🏿b✋🏼c')).toBe('abc')
})
})