A platform for community discussion. Free, open, simple.
FIX: Don't allow category slugs to be entirely digits
Daniel Waterworth226fc07a1763
diff --git a/lib/slug.rb b/lib/slug.rbindex f50492bddfd..25f2325b0f1 100644--- a/lib/slug.rb+++ b/lib/slug.rb@@ -19,8 +19,6 @@ module Slugwhen :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 : slugend@@ -33,6 +31,9 @@ module Slugprivatedef 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: '')