mirror of
https://github.com/discourse/discourse.git
synced 2025-04-15 00:21:42 +08:00
FIX: don't extract links from elided parts
This commit is contained in:
parent
8577b7e2cc
commit
7acdbc8448
@ -328,8 +328,8 @@ module PrettyText
|
||||
def self.extract_links(html)
|
||||
links = []
|
||||
doc = Nokogiri::HTML.fragment(html)
|
||||
# remove href inside quotes
|
||||
doc.css("aside.quote a").each { |l| l["href"] = "" }
|
||||
# remove href inside quotes & elided part
|
||||
doc.css("aside.quote a, .elided a").each { |l| l["href"] = "" }
|
||||
|
||||
# extract all links from the post
|
||||
doc.css("a").each { |l|
|
||||
|
@ -188,6 +188,10 @@ HTML
|
||||
expect(PrettyText.extract_links("<aside class='quote'>not a linked quote</aside>\n").to_a).to be_empty
|
||||
end
|
||||
|
||||
it "doesn't extract links from elided parts" do
|
||||
expect(PrettyText.extract_links("<details class='elided'><a href='http://cnn.com'>cnn</a></details>\n").to_a).to be_empty
|
||||
end
|
||||
|
||||
def extract_urls(text)
|
||||
PrettyText.extract_links(text).map(&:url).to_a
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user