Skip to content

Commit

Permalink
FIX: Remove multiple consecutive dashes from tag names (discourse#24520)
Browse files Browse the repository at this point in the history
  • Loading branch information
gschlager authored Nov 22, 2023
1 parent fef14c0 commit 9f3399c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/discourse_tagging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -724,8 +724,8 @@ def self.clean_tag(tag)
tag.strip!
tag.gsub!(/[[:space:]]+/, "-")
tag.gsub!(/[^[:word:][:punct:]]+/, "")
tag.squeeze!("-")
tag.gsub!(TAGS_FILTER_REGEXP, "")
tag.squeeze!("-")
tag[0...SiteSetting.max_tag_length]
end

Expand Down
5 changes: 5 additions & 0 deletions spec/lib/discourse_tagging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,11 @@
it "removes zero-width spaces" do
expect(DiscourseTagging.clean_tag("hel\ufefflo")).to eq("hello")
end

it "removes multiple consecutive dashes" do
expect(DiscourseTagging.clean_tag("hello---world")).to eq("hello-world")
expect(DiscourseTagging.clean_tag("Finances & Accounting")).to eq("finances-accounting")
end
end
end

Expand Down

0 comments on commit 9f3399c

Please sign in to comment.