diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 6dacab922d..3f30fbd3f5 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -328,8 +328,8 @@ module PrettyText def self.extract_links(html) links = [] doc = Nokogiri::HTML.fragment(html) - # remove href inside quotes - doc.css("aside.quote a").each { |l| l["href"] = "" } + # remove href inside quotes & elided part + doc.css("aside.quote a, .elided a").each { |l| l["href"] = "" } # extract all links from the post doc.css("a").each { |l| diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 94fe6437f0..d01cd51275 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -188,6 +188,10 @@ HTML expect(PrettyText.extract_links("\n").to_a).to be_empty end + it "doesn't extract links from elided parts" do + expect(PrettyText.extract_links("
cnn
\n").to_a).to be_empty + end + def extract_urls(text) PrettyText.extract_links(text).map(&:url).to_a end