diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index a627ac13f45..d72496074cb 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -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 } diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index d01cd512751..c30be629f6b 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -208,6 +208,10 @@ HTML expect(extract_urls("")).to eq(["/t/topic/1234/4567"]) end + it "should not extract links to anchors" do + expect(extract_urls("TOS")).to eq([]) + end + it "should not extract links inside quotes" do links = PrettyText.extract_links(" http://useless1.com