File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
app/services/discourse_translator Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ def self.language_supported?(detected_lang)
7575 def self . strip_tags_for_detection ( detection_text )
7676 html_doc = Nokogiri ::HTML ::DocumentFragment . parse ( detection_text )
7777 html_doc . css ( "img" ) . remove
78- html_doc . css ( "a" ) . remove
78+ html_doc . css ( "a.mention " ) . remove
7979 html_doc . to_html
8080 end
8181
Original file line number Diff line number Diff line change @@ -41,11 +41,22 @@ class EmptyTranslator < DiscourseTranslator::Base
4141 expect ( DiscourseTranslator ::Base . text_for_detection ( post ) ) . to eq ( "" )
4242 end
4343
44- it "strips anchor tags" do
45- post . cooked = "<a href='http://cat.com/image.png' />"
44+ it "strips @ mention anchor tags" do
45+ post . cooked = "<a class='mention' href='http://cat.com/image.png' />"
4646 expect ( DiscourseTranslator ::Base . text_for_detection ( post ) ) . to eq ( "" )
4747 end
4848
49+ it "leaves other anchor tags alone" do
50+ cooked = <<~HTML
51+ < p >
52+ < a href ="http://cat.com/image.png "> </ a >
53+ < a class ="derp " href ="http://cat.com/image.png "> </ a >
54+ </ p >
55+ HTML
56+ post . cooked = cooked
57+ expect ( DiscourseTranslator ::Base . text_for_detection ( post ) ) . to eq ( cooked )
58+ end
59+
4960 it "truncates to DETECTION_CHAR_LIMIT of 1000" do
5061 post . cooked = "a" * 1001
5162 expect ( DiscourseTranslator ::Base . text_for_detection ( post ) . length ) . to eq ( 1000 )
You can’t perform that action at this time.
0 commit comments