FIX: don't extract links to anchors

This commit is contained in:
Régis Hanol 2016-04-15 20:02:18 +02:00
parent fd93fff39b
commit 1a621f3393
2 changed files with 5 additions and 1 deletions

View file

@ -333,7 +333,7 @@ module PrettyText
# extract all links from the post
doc.css("a").each { |l|
unless l["href"].blank?
unless l["href"].blank? || "#".freeze == l["href"][0]
links << DetectedLink.new(l["href"])
end
}

View file

@ -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"])
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
links = PrettyText.extract_links("
<a href='http://body_only.com'>http://useless1.com</a>