Skip to content

A platform for community discussion. Free, open, simple.

FIX: do not replace twitter handles in URLs

Arpit Jalan6cd0b7316a6f
diff --git a/lib/twitter_api.rb b/lib/twitter_api.rb
index d85df9b9a03..5f6a6bfb29c 100644
--- a/lib/twitter_api.rb
+++ b/lib/twitter_api.rb
@@ -54,14 +54,14 @@ class TwitterApi
def link_handles_in(text)
text.scan(/(?:^|\s)@(\w+)/).flatten.uniq.each do |handle|
- text.gsub!("@#{handle}", [
- "<a href='https://twitter.com/#{handle}' target='_blank'>",
+ text.gsub!(/(?:^|\s)@#{handle}/, [
+ " <a href='https://twitter.com/#{handle}' target='_blank'>",
"@#{handle}",
"</a>"
].join)
end
- text
+ text.strip
end
def link_hashtags_in(text)