diff --git a/app/assets/javascripts/discourse/models/category.js.es6 b/app/assets/javascripts/discourse/models/category.js.es6 index 11bdbf9b8a3..665961e03d7 100644 --- a/app/assets/javascripts/discourse/models/category.js.es6 +++ b/app/assets/javascripts/discourse/models/category.js.es6 @@ -283,7 +283,13 @@ Category.reopenClass({ return ( item && item.get("parentCategory") === parentCategory && - Category.slugFor(item) === parentSlug + "/" + slug + ( + Discourse.SiteSettings.slug_generation_method !== "encoded" && + Category.slugFor(item) === parentSlug + "/" + slug + || + Discourse.SiteSettings.slug_generation_method === "encoded" && + Category.slugFor(item) === encodeURI(parentSlug) + "/" + encodeURI(slug) + ) ); }); } diff --git a/app/models/category.rb b/app/models/category.rb index e76089baad3..d3273ea63d0 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -607,7 +607,8 @@ class Category < ActiveRecord::Base end def self.query_parent_category(parent_slug) - self.where(slug: parent_slug, parent_category_id: nil).pluck(:id).first || + encoded_parent_slug = CGI.escape(parent_slug) if SiteSetting.slug_generation_method == 'encoded' + self.where(slug: (encoded_parent_slug || parent_slug), parent_category_id: nil).pluck(:id).first || self.where(id: parent_slug.to_i).pluck(:id).first end