Skip to content

Commit

Permalink
Fix find_by_unicode for country emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanitoFatas committed Jun 9, 2016
1 parent 63ed2fe commit b13819d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/twemoji.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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)
ICODES[must_str("%4.4x" % raw.ord)]
ICODES[must_str(raw.split("").map { |r| "%4.4x" % r.ord }.join("-"))]
end

# Render raw emoji unicode from emoji text or emoji code.
Expand Down
4 changes: 4 additions & 0 deletions test/twemoji_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def test_find_by_unicode
assert_equal ":heart_eyes:", Twemoji.find_by_unicode("😍")
end

def test_find_by_unicode_country_flag
assert_equal ":es:", Twemoji.find_by_unicode("🇪🇸")
end

def test_find_by_escaped_unicode
assert_equal ":heart_eyes:", Twemoji.find_by_unicode("\u{1f60d}")
end
Expand Down

0 comments on commit b13819d

Please sign in to comment.