forked from fedi/mastodon
Fix not being able to input featured tag with #
(#19535)
This commit is contained in:
parent
ad83e64795
commit
3b024c563c
|
@ -19,6 +19,8 @@ class FeaturedTag < ApplicationRecord
|
||||||
validate :validate_tag_name, on: :create
|
validate :validate_tag_name, on: :create
|
||||||
validate :validate_featured_tags_limit, on: :create
|
validate :validate_featured_tags_limit, on: :create
|
||||||
|
|
||||||
|
before_validation :strip_name
|
||||||
|
|
||||||
before_create :set_tag
|
before_create :set_tag
|
||||||
before_create :reset_data
|
before_create :reset_data
|
||||||
|
|
||||||
|
@ -48,6 +50,12 @@ class FeaturedTag < ApplicationRecord
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def strip_name
|
||||||
|
return unless defined?(@name)
|
||||||
|
|
||||||
|
@name = @name&.strip&.gsub(/\A#/, '')
|
||||||
|
end
|
||||||
|
|
||||||
def set_tag
|
def set_tag
|
||||||
self.tag = Tag.find_or_create_by_names(@name)&.first
|
self.tag = Tag.find_or_create_by_names(@name)&.first
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue