From 115aca89c25bfed12288f62e6865571b3883f28d Mon Sep 17 00:00:00 2001 From: Tim Davies Date: Sat, 19 Oct 2024 21:37:43 +0100 Subject: [PATCH] Support numerical keycap emoji by including 2 byte runes --- search.go | 2 +- tests/search_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/search.go b/search.go index 6d3268e..fc3ad5c 100644 --- a/search.go +++ b/search.go @@ -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 } diff --git a/tests/search_test.go b/tests/search_test.go index 782968b..520f9bf 100644 --- a/tests/search_test.go +++ b/tests/search_test.go @@ -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 := "起坎特在🇫🇷队的作用更 哈哈哈"