FIX: should allow non-ASCII slugs for category pages.

FIX: should allow non-ASCII slugs for category pages.

diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb
index f9220b4..1d0525b 100644
--- a/app/controllers/list_controller.rb
+++ b/app/controllers/list_controller.rb
@@ -348,6 +348,11 @@ class ListController < ApplicationController
 
     current_slug = params.require(:category_slug_path_with_id)
     real_slug = @category.full_slug("/")
+
+    if SiteSetting.slug_generation_method == "encoded"
+      current_slug = current_slug.split("/").map { |slug| CGI.escape(slug) }.join("/")
+    end
+
     if current_slug != real_slug
       url = request.fullpath.gsub(current_slug, real_slug)
       return redirect_to path(url), status: 301
diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb
index 7afe542..2221cb3 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -368,6 +368,19 @@ RSpec.describe ListController do
         end
       end
 
+      context 'with encoded slug in the category' do
+        let(:category) { Fabricate(:category, slug: "தமிழ்") }
+
+        before do
+          SiteSetting.slug_generation_method = "encoded"
+        end
+
+        it "succeeds" do
+          get "/c/#{category.slug}/#{category.id}/l/latest"
+          expect(response.status).to eq(200)
+        end
+      end
+
       context 'with a link that has a parent slug, slug and id in its path' do
         let(:child_category) { Fabricate(:category_with_definition, parent_category: category) }
 

GitHub sha: 691edc16

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

https://meta.discourse.org/t/newly-added-non-ascii-category-page-does-not-load/158971/14