FIX: Remove multiple consecutive dashes from tag names (#24520)

This commit is contained in:
Gerhard Schlager 2023-11-23 00:57:12 +01:00 committed by GitHub
parent fef14c004c
commit 9f3399ca8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -724,8 +724,8 @@ module DiscourseTagging
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

View File

@ -1479,6 +1479,11 @@ RSpec.describe DiscourseTagging do
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