A platform for community discussion. Free, open, simple.
FIX: Can't clean a tag if the given string is frozen.
Guo Xiang Tan8fa59f05480b
diff --git a/lib/discourse_tagging.rb b/lib/discourse_tagging.rbindex 2c0519cd199..ac2061b41f9 100644--- a/lib/discourse_tagging.rb+++ b/lib/discourse_tagging.rb@@ -202,10 +202,13 @@ module DiscourseTaggingenddef self.clean_tag(tag)+ tag = tag.duptag.downcase! if SiteSetting.force_lowercase_tags- tag.strip- .gsub(/\s+/, '-').squeeze('-')- .gsub(TAGS_FILTER_REGEXP, '')[0...SiteSetting.max_tag_length]+ tag.strip!+ tag.gsub!(/\s+/, '-')+ tag.squeeze!('-')+ tag.gsub!(TAGS_FILTER_REGEXP, '')+ tag[0...SiteSetting.max_tag_length]enddef self.tags_for_saving(tags_arg, guardian, opts = {})diff --git a/spec/components/discourse_tagging_spec.rb b/spec/components/discourse_tagging_spec.rbindex 5d52375406b..f080a03f8cb 100644--- a/spec/components/discourse_tagging_spec.rb+++ b/spec/components/discourse_tagging_spec.rb@@ -209,7 +209,8 @@ describe DiscourseTagging dodescribe "clean_tag" doit "downcases new tags if setting enabled" do- expect(DiscourseTagging.clean_tag("HeLlO")).to eq("hello")+ expect(DiscourseTagging.clean_tag("HeLlO".freeze)).to eq("hello")+SiteSetting.force_lowercase_tags = falseexpect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")end