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
4 changes: 2 additions & 2 deletions lib/twemoji.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def self.find_by_text(text)
# @param code [String] Emoji code to find text.
# @return [String] Emoji Text.
def self.find_by_code(code)
invert_codes[must_str(code)]
invert_codes[must_str(code).gsub(/(-fe0e|-fe0f)/, '')]
end

# Find emoji text by raw emoji unicode.
Expand All @@ -70,7 +70,7 @@ def self.find_by_code(code)
# @param raw [String] Emoji raw unicode to find text.
# @return [String] Emoji Text.
def self.find_by_unicode(raw)
invert_codes[unicode_to_str(raw)]
invert_codes[unicode_to_str(raw).gsub(/(-fe0e|-fe0f)/, '')]
end

# Render raw emoji unicode from emoji text or emoji code.
Expand Down
12 changes: 6 additions & 6 deletions lib/twemoji/data/emoji-unicode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,8 @@
":man-woman-girl:": 1f468-200d-1f469-200d-1f467
":man-woman-girl-boy:": 1f468-200d-1f469-200d-1f467-200d-1f466
":man-woman-girl-girl:": 1f468-200d-1f469-200d-1f467-200d-1f467
":man-heart-man:": 1f468-200d-2764-fe0f-200d-1f468
":man-kiss-man:": 1f468-200d-2764-fe0f-200d-1f48b-200d-1f468
":man-heart-man:": 1f468-200d-2764-200d-1f468
":man-kiss-man:": 1f468-200d-2764-200d-1f48b-200d-1f468
":woman::skin-tone-2:": 1f469-1f3fb
":woman::skin-tone-3:": 1f469-1f3fc
":woman::skin-tone-4:": 1f469-1f3fd
Expand All @@ -804,10 +804,10 @@
":woman-woman-girl:": 1f469-200d-1f469-200d-1f467
":woman-woman-girl-boy:": 1f469-200d-1f469-200d-1f467-200d-1f466
":woman-woman-girl-girl:": 1f469-200d-1f469-200d-1f467-200d-1f467
":woman-heart-man:": 1f469-200d-2764-fe0f-200d-1f468
":woman-heart-woman:": 1f469-200d-2764-fe0f-200d-1f469
":woman-kiss-man:": 1f469-200d-2764-fe0f-200d-1f48b-200d-1f468
":woman-kiss-woman:": 1f469-200d-2764-fe0f-200d-1f48b-200d-1f469
":woman-heart-man:": 1f469-200d-2764-200d-1f468
":woman-heart-woman:": 1f469-200d-2764-200d-1f469
":woman-kiss-man:": 1f469-200d-2764-200d-1f48b-200d-1f468
":woman-kiss-woman:": 1f469-200d-2764-200d-1f48b-200d-1f469
":family:": 1f46a
":couple:": 1f46b
":two_men_holding_hands:": 1f46c
Expand Down
11 changes: 9 additions & 2 deletions test/twemoji_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def test_find_by_escaped_unicode
assert_equal ":heart_eyes:", Twemoji.find_by_unicode("\u{1f60d}")
end

def test_find_by_code_including_emoji_presentation_selector
assert_equal ":eye::left_speech_bubble:", Twemoji.find_by_code("1f441-fe0f-200d-1f5e8-fe0f")
end

def test_find_by_unicode_including_emoji_presentation_selector
assert_equal ":eye::left_speech_bubble:", Twemoji.find_by_unicode("\u{1f441}\u{fe0f}\u{200d}\u{1f5e8}\u{fe0f}")
end

def test_parse_plus_one
expected = %(<img draggable="false" title=":+1:" alt="👍" src="https://twemoji.maxcdn.com/2/svg/1f44d.svg" class="emoji">)

Expand Down Expand Up @@ -211,7 +219,7 @@ def test_parse_by_unicode_multiple_html
expected = %(<p><img draggable="false" title=":cookie:" alt="🍪" src="https://twemoji.maxcdn.com/2/svg/1f36a.svg" class="emoji" aria-label="emoji: cookie"><img draggable="false" title=":birthday:" alt="🎂" src="https://twemoji.maxcdn.com/2/svg/1f382.svg" class="emoji" aria-label="emoji: birthday"></p>)
aria_label = ->(name) { 'emoji: ' + name.gsub(":", '') }
assert_equal expected, Twemoji.parse(Nokogiri::HTML::DocumentFragment.parse("<p>🍪🎂</p>"), img_attrs: {'aria-label'=> aria_label } ).to_html
end
end

def test_parse_by_unicode_multiple_mix_codepoint_name_html
expected = %(<p><img draggable="false" title=":cookie:" alt="🍪" src="https://twemoji.maxcdn.com/2/svg/1f36a.svg" class="emoji" aria-label="emoji: cookie"><img draggable="false" title=":birthday:" alt="🎂" src="https://twemoji.maxcdn.com/2/svg/1f382.svg" class="emoji" aria-label="emoji: birthday"></p>)
Expand All @@ -230,5 +238,4 @@ def test_parse_multiple
aria_label = ->(name) { 'emoji: ' + name.gsub(":", '') }
assert_equal expected, Twemoji.parse(":cookie::birthday:", img_attrs: {'aria-label'=> aria_label } )
end

end