mirror of
https://github.com/discourse/discourse.git
synced 2025-06-08 00:27:32 +08:00
FIX: Can't clean a tag if the given string is frozen.
This commit is contained in:
@ -202,10 +202,13 @@ module DiscourseTagging
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.clean_tag(tag)
|
def self.clean_tag(tag)
|
||||||
|
tag = tag.dup
|
||||||
tag.downcase! if SiteSetting.force_lowercase_tags
|
tag.downcase! if SiteSetting.force_lowercase_tags
|
||||||
tag.strip
|
tag.strip!
|
||||||
.gsub(/\s+/, '-').squeeze('-')
|
tag.gsub!(/\s+/, '-')
|
||||||
.gsub(TAGS_FILTER_REGEXP, '')[0...SiteSetting.max_tag_length]
|
tag.squeeze!('-')
|
||||||
|
tag.gsub!(TAGS_FILTER_REGEXP, '')
|
||||||
|
tag[0...SiteSetting.max_tag_length]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.tags_for_saving(tags_arg, guardian, opts = {})
|
def self.tags_for_saving(tags_arg, guardian, opts = {})
|
||||||
|
@ -209,7 +209,8 @@ describe DiscourseTagging do
|
|||||||
|
|
||||||
describe "clean_tag" do
|
describe "clean_tag" do
|
||||||
it "downcases new tags if setting enabled" do
|
it "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 = false
|
SiteSetting.force_lowercase_tags = false
|
||||||
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")
|
expect(DiscourseTagging.clean_tag("HeLlO")).to eq("HeLlO")
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user