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

This commit is contained in:
Vinoth Kannan 2020-07-29 19:47:57 +05:30
parent 3116591dc6
commit 691edc16c9
2 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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) }