FIX: Make category slugs lowercase (PR #11277)

Administrators could specify category slug with upper case characters.


I think that was the last use of Slug.sanitize. I don’t see any plugins using it either. Can we remove or deprecate it? :slightly_smiling_face: (in this or a separate PR, either way)

Changing the review to “request changes” - specs disagree with the implementation :wink:

I do not see it used anywhere. What about removing it completely? :slight_smile:

Yes, that exactly what I did on but the case sensitive-ness of categories slug was breaking it, so that is the whole reason this discussion started!

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

Unfortunately, we cannot get rid of Slug.sanitize, but I renamed it to Slug.for_category. We need it because slug_generation_method should be ignored for categories.

Do we have a test that ensures slugs are case insensitive?

      .filter { |category| category.slug.present? }
      next if category.slug.blank? ||
      new_slug ="_", "-").squeeze('-').gsub(/\A-+|-+\z/, '')[0..255]
      next if new_slug.blank? ||
      .filter { |category| category.slug.present? }
      next if category.slug.blank? ||

There is a list_controller spec to test that a redirect to correct slug happens.