mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: Don't allow category slugs to be entirely digits
This commit is contained in:
parent
8f708bd6e1
commit
226fc07a17
|
@ -19,8 +19,6 @@ module Slug
|
|||
when :encoded then self.encoded_generator(string)
|
||||
when :none then self.none_generator(string)
|
||||
end
|
||||
# Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
||||
slug = (slug =~ /[^\d]/ ? slug : '')
|
||||
slug = self.prettify_slug(slug, max_length: max_length)
|
||||
slug.blank? ? default : slug
|
||||
end
|
||||
|
@ -33,6 +31,9 @@ module Slug
|
|||
private
|
||||
|
||||
def self.prettify_slug(slug, max_length:)
|
||||
# Reject slugs that only contain numbers, because they would be indistinguishable from id's.
|
||||
slug = (slug =~ /[^\d]/ ? slug : '')
|
||||
|
||||
slug
|
||||
.tr("_", "-")
|
||||
.truncate(max_length, omission: '')
|
||||
|
|
Loading…
Reference in New Issue
Block a user