Skip to content

Commit

Permalink
Fix a rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
nattsw committed Jan 24, 2025
1 parent 0302b81 commit 23a6131
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/services/discourse_translator/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def self.strip_tags_for_detection(detection_text)
end

def self.text_for_detection(topic_or_post)
strip_tags_for_detection(
get_text(topic_or_post).truncate(DETECTION_CHAR_LIMIT, omission: nil),
strip_tags_for_detection(get_text(topic_or_post)).truncate(
DETECTION_CHAR_LIMIT,
omission: nil,
)
end

Expand Down
5 changes: 5 additions & 0 deletions spec/services/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class EmptyTranslator < DiscourseTranslator::Base
post.cooked = text
expect(DiscourseTranslator::Base.text_for_detection(post)).to eq(text)
end

it "strips text before truncation" do
post.cooked = "<img src='http://example.com/image.png' />" + "a" * 1000
expect(DiscourseTranslator::Base.text_for_detection(post)).to eq("a" * 1000)
end
end

describe ".text_for_translation" do
Expand Down

0 comments on commit 23a6131

Please sign in to comment.