mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Navigating to home via route name (#24460)
This commit is contained in:
@@ -30,7 +30,11 @@ export function homepageDestination() {
|
|||||||
|
|
||||||
function rewriteIfNeeded(url, transition) {
|
function rewriteIfNeeded(url, transition) {
|
||||||
const intentUrl = transition?.intent?.url;
|
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];
|
const params = url.split("?", 2)[1];
|
||||||
url = "/";
|
url = "/";
|
||||||
if (params) {
|
if (params) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export default class DiscoveryIndex extends DiscourseRoute {
|
|||||||
|
|
||||||
beforeModel(transition) {
|
beforeModel(transition) {
|
||||||
const url = transition.intent.url;
|
const url = transition.intent.url;
|
||||||
const params = url.split("?", 2)[1];
|
const params = url?.split("?", 2)[1];
|
||||||
let destination = homepageDestination();
|
let destination = homepageDestination();
|
||||||
if (params) {
|
if (params) {
|
||||||
destination += `&${params}`;
|
destination += `&${params}`;
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ acceptance("Dynamic homepage handling", function () {
|
|||||||
await router.transitionTo("/").followRedirects();
|
await router.transitionTo("/").followRedirects();
|
||||||
assertOnLatest("/");
|
assertOnLatest("/");
|
||||||
|
|
||||||
|
await router.transitionTo("discovery.index").followRedirects();
|
||||||
|
assertOnLatest("/");
|
||||||
|
|
||||||
await click(".nav-item_latest a");
|
await click(".nav-item_latest a");
|
||||||
assertOnLatest("/latest");
|
assertOnLatest("/latest");
|
||||||
|
|
||||||
@@ -65,6 +68,9 @@ acceptance("Dynamic homepage handling", function () {
|
|||||||
await router.transitionTo("/").followRedirects();
|
await router.transitionTo("/").followRedirects();
|
||||||
assertOnCategories("/");
|
assertOnCategories("/");
|
||||||
|
|
||||||
|
await router.transitionTo("discovery.index").followRedirects();
|
||||||
|
assertOnCategories("/");
|
||||||
|
|
||||||
await click(".nav-item_categories a");
|
await click(".nav-item_categories a");
|
||||||
assertOnCategories("/categories");
|
assertOnCategories("/categories");
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user