FIX: category slug route was not working for subfolder setup
https://meta.discourse.org/t/relative-url-root-issues-incorrect-latest-link-incorrect-redirect/163266 URLs like `/forum/c/staff` (subfolder setup) were landing on `/forum/forum/c/staff/3`. Note the extra "/forum". This commit strips the redundant subfolder path from category URL.
This commit is contained in:
parent
ddcf0d7d01
commit
32d6286bea
|
@ -372,6 +372,10 @@ class ListController < ApplicationController
|
|||
|
||||
if current_slug != real_slug
|
||||
url = request.fullpath.gsub(current_slug, real_slug)
|
||||
if ActionController::Base.config.relative_url_root
|
||||
url = url.sub(ActionController::Base.config.relative_url_root, "")
|
||||
end
|
||||
|
||||
return redirect_to path(url), status: 301
|
||||
end
|
||||
|
||||
|
|
|
@ -729,7 +729,15 @@ RSpec.describe ListController do
|
|||
end
|
||||
|
||||
context "with subfolder" do
|
||||
it "redirects to URL containing the updated slug" do
|
||||
it "main category redirects to URL containing the updated slug" do
|
||||
set_subfolder "/forum"
|
||||
get "/c/#{category.slug}"
|
||||
|
||||
expect(response.status).to eq(301)
|
||||
expect(response).to redirect_to("/forum/c/#{category.slug}/#{category.id}")
|
||||
end
|
||||
|
||||
it "sub-sub-category redirects to URL containing the updated slug" do
|
||||
set_subfolder "/forum"
|
||||
get "/c/hello/world/bye/#{subsubcategory.id}"
|
||||
|
||||
|
|
Loading…
Reference in New Issue