mirror of
https://github.com/discourse/discourse.git
synced 2025-03-25 18:06:39 +08:00
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
|
||||
|
||||
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}", [
|
||||
"<a href='https://twitter.com/#{handle}' target='_blank'>",
|
||||
"@#{handle}",
|
||||
@ -68,7 +68,7 @@ class TwitterApi
|
||||
end
|
||||
|
||||
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}", [
|
||||
"<a href='https://twitter.com/search?q=%23#{hashtag}' ",
|
||||
"target='_blank'>",
|
||||
|
Loading…
x
Reference in New Issue
Block a user