mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: don't extract links to anchors
This commit is contained in:
parent
fd93fff39b
commit
1a621f3393
2 changed files with 5 additions and 1 deletions
|
@ -333,7 +333,7 @@ module PrettyText
|
||||||
|
|
||||||
# extract all links from the post
|
# extract all links from the post
|
||||||
doc.css("a").each { |l|
|
doc.css("a").each { |l|
|
||||||
unless l["href"].blank?
|
unless l["href"].blank? || "#".freeze == l["href"][0]
|
||||||
links << DetectedLink.new(l["href"])
|
links << DetectedLink.new(l["href"])
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,6 +208,10 @@ HTML
|
||||||
expect(extract_urls("<aside class=\"quote\" data-topic=\"1234\" data-post=\"4567\">aside</aside>")).to eq(["/t/topic/1234/4567"])
|
expect(extract_urls("<aside class=\"quote\" data-topic=\"1234\" data-post=\"4567\">aside</aside>")).to eq(["/t/topic/1234/4567"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should not extract links to anchors" do
|
||||||
|
expect(extract_urls("<a href='#tos'>TOS</a>")).to eq([])
|
||||||
|
end
|
||||||
|
|
||||||
it "should not extract links inside quotes" do
|
it "should not extract links inside quotes" do
|
||||||
links = PrettyText.extract_links("
|
links = PrettyText.extract_links("
|
||||||
<a href='http://body_only.com'>http://useless1.com</a>
|
<a href='http://body_only.com'>http://useless1.com</a>
|
||||||
|
|
Loading…
Reference in a new issue