From 863c0cdecc357609544d5d5a694801da6207a9f1 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 5 Dec 2023 15:37:01 +0000 Subject: [PATCH] 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. --- app/assets/javascripts/discourse/app/routes/topic.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/app/routes/topic.js b/app/assets/javascripts/discourse/app/routes/topic.js index b1802aeca48..3a9c8d263d1 100644 --- a/app/assets/javascripts/discourse/app/routes/topic.js +++ b/app/assets/javascripts/discourse/app/routes/topic.js @@ -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; }