Skip to content

Commit 541aede

Browse files
committed
Ruby: Fix auto_link so that it doesn't remove emoji
This fixes #275
1 parent 4f3c985 commit 541aede

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

rb/lib/twitter-text/autolink.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def auto_link_entities(text, entities, options = {}, &block)
8181
link_to_screen_name(entity, chars, options, &block)
8282
elsif entity[:cashtag]
8383
link_to_cashtag(entity, chars, options, &block)
84+
elsif entity[:emoji]
85+
entity[:emoji]
8486
end
8587
end
8688
end

rb/spec/autolinking_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ def url; end
1818
@autolinked_text = TestAutolink.new.auto_link(original_text) if original_text
1919
end
2020

21+
describe "plain text" do
22+
context "plain text with emoji" do
23+
def original_text; "gotcha 👍"; end
24+
25+
it "should be unchanged" do
26+
expect(@autolinked_text).to eq("gotcha 👍")
27+
end
28+
end
29+
end
30+
2131
describe "username autolinking" do
2232
context "username preceded by a space" do
2333
def original_text; "hello @jacob"; end

0 commit comments

Comments
 (0)