mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Don't extract links from empty quotes
This commit is contained in:
parent
010da29957
commit
64355c989e
2 changed files with 5 additions and 1 deletions
|
@ -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}"
|
||||
|
|
|
@ -135,6 +135,10 @@ describe PrettyText do
|
|||
PrettyText.excerpt("<a href='http://cnn.com'>cnn</a>",2).should == "<a href='http://cnn.com'>cn…</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
|
||||
|
|
Loading…
Reference in a new issue