FIX: Preserve `preview_theme_id` param on topic redirects (#23965)
Why this change?
When the URL `/t/1234?preview_theme_id=21` is loaded, we redirect to
`/t/<topic slug>/1234` stripping the `preview_theme_id` query params.
What does this change do?
This change builds on 61248652cd
and
simply adds the `preview_theme_id` query param when redirecting.
This commit is contained in:
parent
788651467b
commit
b4eb078b0e
|
@ -1253,7 +1253,7 @@ class TopicsController < ApplicationController
|
|||
raise(SiteSetting.detailed_404 ? ex : Discourse::NotFound)
|
||||
end
|
||||
|
||||
opts = params.slice(:page, :print, :filter_top_level_replies)
|
||||
opts = params.slice(:page, :print, :filter_top_level_replies, :preview_theme_id)
|
||||
opts.delete(:page) if params[:page] == 0
|
||||
|
||||
url = topic.relative_url
|
||||
|
|
|
@ -2177,7 +2177,7 @@ RSpec.describe TopicsController do
|
|||
it "preserves only select query params" do
|
||||
get "/t/external_id/asdf.json", params: { filter_top_level_replies: true }
|
||||
expect(response.status).to eq(301)
|
||||
expect(response).to redirect_to(topic.relative_url + ".json?filter_top_level_replies=true")
|
||||
expect(response).to redirect_to("#{topic.relative_url}.json?filter_top_level_replies=true")
|
||||
|
||||
get "/t/external_id/asdf.json", params: { not_valid: true }
|
||||
expect(response.status).to eq(301)
|
||||
|
@ -2186,13 +2186,18 @@ RSpec.describe TopicsController do
|
|||
get "/t/external_id/asdf.json", params: { filter_top_level_replies: true, post_number: 9999 }
|
||||
expect(response.status).to eq(301)
|
||||
expect(response).to redirect_to(
|
||||
topic.relative_url + "/9999.json?filter_top_level_replies=true",
|
||||
"#{topic.relative_url}/9999.json?filter_top_level_replies=true",
|
||||
)
|
||||
|
||||
get "/t/external_id/asdf.json", params: { filter_top_level_replies: true, print: true }
|
||||
get "/t/external_id/asdf.json",
|
||||
params: {
|
||||
filter_top_level_replies: true,
|
||||
print: true,
|
||||
preview_theme_id: 9999,
|
||||
}
|
||||
expect(response.status).to eq(301)
|
||||
expect(response).to redirect_to(
|
||||
topic.relative_url + ".json?print=true&filter_top_level_replies=true",
|
||||
"#{topic.relative_url}.json?print=true&filter_top_level_replies=true&preview_theme_id=9999",
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue