FIX: should allow non-ASCII slugs for category pages.
This commit is contained in:
parent
3116591dc6
commit
691edc16c9
|
@ -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
|
||||
|
|
|
@ -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) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue