From 6cd0b7316a6ffb7205538fd9f4aaa1fa6b5d15c1 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Thu, 17 May 2018 00:18:19 +0530 Subject: [PATCH] FIX: do not replace twitter handles in URLs --- lib/twitter_api.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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}", [ - "", + text.gsub!(/(?:^|\s)@#{handle}/, [ + " ", "@#{handle}", "" ].join) end - text + text.strip end def link_hashtags_in(text)