Browse Source

Fix multipoint shortcode bug (#4387)

* Fix multipoint shortcode bug

* Added testcase for composite emoji shortcode
closed-social-v3
Ondřej Hruška 7 years ago
committed by Eugen Rochko
parent
commit
f49339ca9c
2 changed files with 6 additions and 1 deletions
  1. +1
    -1
      app/lib/emoji.rb
  2. +5
    -0
      spec/helpers/emoji_helper_spec.rb

+ 1
- 1
app/lib/emoji.rb View File

@ -32,7 +32,7 @@ class Emoji
def codepoint_to_unicode(codepoint)
if codepoint.include?('-')
codepoint.split('-').map(&:hex).pack('U')
codepoint.split('-').map(&:hex).pack('U*')
else
[codepoint.hex].pack('U')
end

+ 5
- 0
spec/helpers/emoji_helper_spec.rb View File

@ -7,6 +7,11 @@ RSpec.describe EmojiHelper, type: :helper do
expect(emojify(text)).to eq '📖 Book'
end
it 'converts composite emoji shortcodes to unicode' do
text = ':couple_ww:'
expect(emojify(text)).to eq '👩❤👩'
end
it 'does not convert shortcodes that are part of a string into unicode' do
text = ':see_no_evil::hear_no_evil::speak_no_evil:'
expect(emojify(text)).to eq text

Loading…
Cancel
Save