FIX: Ensure slugless topic URLs are correctly redirected (#24719)

Using `DiscourseURL.routeTo` with `replaceURL: true` wouldn't cause a true Ember redirect. That meant that the transition source would be be replaced in the browser's history stack, and the 'back' button wouldn't work as expected. Instead, we can use the router service to perform a proper redirect.
This commit is contained in:
David Taylor 2023-12-05 15:37:01 +00:00 committed by GitHub
parent cae2b83af8
commit 863c0cdecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -355,12 +355,8 @@ const TopicRoute = DiscourseRoute.extend({
model(params, transition) {
if (params.slug.match(ID_CONSTRAINT)) {
transition.abort();
DiscourseURL.routeTo(`/t/topic/${params.slug}/${params.id}`, {
replaceURL: true,
});
// URL with no slug - redirect to a URL with placeholder slug
this.router.transitionTo(`/t/-/${params.slug}/${params.id}`);
return;
}