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 8, 2016
1 parent 333418c commit 051f5a5
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 @@ -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[must_str("%4.4x" % raw.ord)]
invert_codes[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 @@ -64,6 +64,10 @@ def test_find_by_unicode
assert_equal ":heart_eyes:", Twemoji.find_by_unicode("😍")
end

def test_find_by_unicode_country_flag
assert_equal ":flag-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 051f5a5

Please sign in to comment.