FIX: first @mention/#hashtag is not a hyperlink in Twitter onebox
https://meta.discourse.org/t/first-mention-is-not-a-hyperlink-in-twitter-onebox/65665
This commit is contained in:
parent
74f6894606
commit
c47658c7c5
|
@ -56,7 +56,7 @@ class TwitterApi
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def link_handles_in(text)
|
def link_handles_in(text)
|
||||||
text.scan(/\s@(\w+)/).flatten.uniq.each do |handle|
|
text.scan(/(?:^|\s)@(\w+)/).flatten.uniq.each do |handle|
|
||||||
text.gsub!("@#{handle}", [
|
text.gsub!("@#{handle}", [
|
||||||
"<a href='https://twitter.com/#{handle}' target='_blank'>",
|
"<a href='https://twitter.com/#{handle}' target='_blank'>",
|
||||||
"@#{handle}",
|
"@#{handle}",
|
||||||
|
@ -68,7 +68,7 @@ class TwitterApi
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_hashtags_in(text)
|
def link_hashtags_in(text)
|
||||||
text.scan(/\s#(\w+)/).flatten.uniq.each do |hashtag|
|
text.scan(/(?:^|\s)#(\w+)/).flatten.uniq.each do |hashtag|
|
||||||
text.gsub!("##{hashtag}", [
|
text.gsub!("##{hashtag}", [
|
||||||
"<a href='https://twitter.com/search?q=%23#{hashtag}' ",
|
"<a href='https://twitter.com/search?q=%23#{hashtag}' ",
|
||||||
"target='_blank'>",
|
"target='_blank'>",
|
||||||
|
|
Loading…
Reference in New Issue