Skip to content

Commit

Permalink
Support numerical keycap emoji by including 2 byte runes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdvs committed Oct 19, 2024
1 parent 38ed444 commit 115aca8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion search.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func FindAll(input string) (detectedEmojis SearchResults) {

// Ignore any basic runes, we'll get funny partials
// that we dont care about
if len(hexKey) < 4 {
if len(hexKey) < 2 {
continue
}

Expand Down
8 changes: 8 additions & 0 deletions tests/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ func TestContinuousEmoji(t *testing.T) {
assert.Equal(t, "abc", emojiRemoved, "There should be no emoji")
}

func TestNumericalKeycaps(t *testing.T) {
str := "0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟"
matches := emoji.FindAll(str)
totalUniqueEmoji := len(matches)

assert.Equal(t, 11, totalUniqueEmoji, "There should be 11 unique emoji")
}

func TestRemoveAllEmojiChinese(t *testing.T) {

str := "起坎特在🇫🇷队的作用更 哈哈哈"
Expand Down

0 comments on commit 115aca8

Please sign in to comment.