diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 0828a2ff012..3e0d563cf26 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -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}" diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 217c58fc2ba..4a6452b1a24 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -135,6 +135,10 @@ describe PrettyText do PrettyText.excerpt("cnn",2).should == "cn…" end + it "doesn't extract empty quotes as links" do + PrettyText.extract_links("\n").to_a.should be_empty + end + it "should be able to extract links" do PrettyText.extract_links("http://bla.com").to_a.should == ["http://cnn.com"] end