A platform for community discussion. Free, open, simple.
FIX: Remove multiple consecutive dashes from tag names (#24520)
Gerhard Schlager9f3399ca8f8c
diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rbindex fa70a4407af..a964a8a22a0 100644--- a/lib/discourse_tagging.rb+++ b/lib/discourse_tagging.rb@@ -724,8 +724,8 @@ module DiscourseTaggingtag.strip!tag.gsub!(/[[:space:]]+/, "-")tag.gsub!(/[^[:word:][:punct:]]+/, "")- tag.squeeze!("-")tag.gsub!(TAGS_FILTER_REGEXP, "")+ tag.squeeze!("-")tag[0...SiteSetting.max_tag_length]enddiff --git a/spec/lib/discourse_tagging_spec.rb b/spec/lib/discourse_tagging_spec.rbindex 996e0ee423a..42b0a8ee348 100644--- a/spec/lib/discourse_tagging_spec.rb+++ b/spec/lib/discourse_tagging_spec.rb@@ -1479,6 +1479,11 @@ RSpec.describe DiscourseTagging doit "removes zero-width spaces" doexpect(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")+ endendend