mirror of
https://github.com/discourse/discourse.git
synced 2026-08-13 06:25:11 -05:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user