FIX: Navigating to home via route name (#24460)

This commit is contained in:
David Taylor 2023-11-20 13:51:03 +00:00 committed by GitHub
parent 5276afa9b2
commit c5affa9ca2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -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) {

View File

@ -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}`;

View File

@ -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");
});