mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
FIX: Have onebox ignore internal links
This commit is contained in:
parent
7d089fdfb5
commit
01855b70b4
2 changed files with 19 additions and 7 deletions
|
@ -213,17 +213,18 @@ module PrettyText
|
|||
end
|
||||
|
||||
def self.extract_links(html)
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
links = []
|
||||
doc.css("a").each do |l|
|
||||
links << l.attributes["href"].to_s
|
||||
end
|
||||
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
# remove href inside quotes
|
||||
doc.css("aside.quote a").each { |l| l["href"] = "" }
|
||||
# extract all links from the post
|
||||
doc.css("a").each { |l| links << l["href"] unless l["href"].empty? }
|
||||
# extract links to quotes
|
||||
doc.css("aside.quote").each do |a|
|
||||
topic_id = a.attributes['data-topic']
|
||||
topic_id = a['data-topic']
|
||||
|
||||
url = "/t/topic/#{topic_id}"
|
||||
if post_number = a.attributes['data-post']
|
||||
if post_number = a['data-post']
|
||||
url << "/#{post_number}"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue