FIX: Don't extract links from empty quotes

This commit is contained in:
Robin Ward 2014-05-20 17:20:52 -04:00
parent 010da29957
commit 64355c989e
2 changed files with 5 additions and 1 deletions

View file

@ -210,7 +210,7 @@ module PrettyText
# extract all links from the post
doc.css("a").each { |l| links << l["href"] unless l["href"].blank? }
# extract links to quotes
doc.css("aside.quote").each do |a|
doc.css("aside.quote[data-topic]").each do |a|
topic_id = a['data-topic']
url = "/t/topic/#{topic_id}"

View file

@ -135,6 +135,10 @@ describe PrettyText do
PrettyText.excerpt("<a href='http://cnn.com'>cnn</a>",2).should == "<a href='http://cnn.com'>cn&hellip;</a>"
end
it "doesn't extract empty quotes as links" do
PrettyText.extract_links("<aside class='quote'>not a linked quote</aside>\n").to_a.should be_empty
end
it "should be able to extract links" do
PrettyText.extract_links("<a href='http://cnn.com'>http://bla.com</a>").to_a.should == ["http://cnn.com"]
end