Skip to content

Commit

Permalink
Merge pull request #304 from mocoso/fix-autolink-for-emoji
Browse files Browse the repository at this point in the history
Ruby: Fix auto_link so that it doesn't remove emoji
  • Loading branch information
dlamacchia committed Mar 25, 2020
2 parents 4f3c985 + 541aede commit 03dcea5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rb/lib/twitter-text/autolink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def auto_link_entities(text, entities, options = {}, &block)
link_to_screen_name(entity, chars, options, &block)
elsif entity[:cashtag]
link_to_cashtag(entity, chars, options, &block)
elsif entity[:emoji]
entity[:emoji]
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions rb/spec/autolinking_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ def url; end
@autolinked_text = TestAutolink.new.auto_link(original_text) if original_text
end

describe "plain text" do
context "plain text with emoji" do
def original_text; "gotcha 👍"; end

it "should be unchanged" do
expect(@autolinked_text).to eq("gotcha 👍")
end
end
end

describe "username autolinking" do
context "username preceded by a space" do
def original_text; "hello @jacob"; end
Expand Down

0 comments on commit 03dcea5

Please sign in to comment.