mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 02:23:37 +08:00
FIX: Navigating to home via route name (#24460)
This commit is contained in:
parent
5276afa9b2
commit
c5affa9ca2
|
@ -30,7 +30,11 @@ export function homepageDestination() {
|
|||
|
||||
function rewriteIfNeeded(url, transition) {
|
||||
const intentUrl = transition?.intent?.url;
|
||||
if (intentUrl?.startsWith(homepageDestination())) {
|
||||
if (
|
||||
intentUrl?.startsWith(homepageDestination()) ||
|
||||
(transition?.intent.name === `discovery.${defaultHomepage()}` &&
|
||||
transition?.intent.queryParams["_discourse_homepage_rewrite"])
|
||||
) {
|
||||
const params = url.split("?", 2)[1];
|
||||
url = "/";
|
||||
if (params) {
|
||||
|
|
|
@ -9,7 +9,7 @@ export default class DiscoveryIndex extends DiscourseRoute {
|
|||
|
||||
beforeModel(transition) {
|
||||
const url = transition.intent.url;
|
||||
const params = url.split("?", 2)[1];
|
||||
const params = url?.split("?", 2)[1];
|
||||
let destination = homepageDestination();
|
||||
if (params) {
|
||||
destination += `&${params}`;
|
||||
|
|
|
@ -29,6 +29,9 @@ acceptance("Dynamic homepage handling", function () {
|
|||
await router.transitionTo("/").followRedirects();
|
||||
assertOnLatest("/");
|
||||
|
||||
await router.transitionTo("discovery.index").followRedirects();
|
||||
assertOnLatest("/");
|
||||
|
||||
await click(".nav-item_latest a");
|
||||
assertOnLatest("/latest");
|
||||
|
||||
|
@ -65,6 +68,9 @@ acceptance("Dynamic homepage handling", function () {
|
|||
await router.transitionTo("/").followRedirects();
|
||||
assertOnCategories("/");
|
||||
|
||||
await router.transitionTo("discovery.index").followRedirects();
|
||||
assertOnCategories("/");
|
||||
|
||||
await click(".nav-item_categories a");
|
||||
assertOnCategories("/categories");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user