From cd4234a75f2f0ac3aaf4ff5315a9540b17d1c5e4 Mon Sep 17 00:00:00 2001 From: Frank Hossfeld Date: Mon, 4 Sep 2023 20:18:15 +0200 Subject: [PATCH] #338 - Error using non hash navigation while reloading - fixed (#339) --- .../core/web/client/NaluPluginCoreWeb.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/nalu-plugin-core-web/src/main/java/com/github/nalukit/nalu/plugin/core/web/client/NaluPluginCoreWeb.java b/nalu-plugin-core-web/src/main/java/com/github/nalukit/nalu/plugin/core/web/client/NaluPluginCoreWeb.java index 1891dae3..4e84fa9e 100644 --- a/nalu-plugin-core-web/src/main/java/com/github/nalukit/nalu/plugin/core/web/client/NaluPluginCoreWeb.java +++ b/nalu-plugin-core-web/src/main/java/com/github/nalukit/nalu/plugin/core/web/client/NaluPluginCoreWeb.java @@ -129,14 +129,13 @@ public static NaluStartModel getNaluStartModel() { // in case we need to remove the parameter, update history ... if (PropertyFactory.INSTANCE.isRemoveUrlParameterAtStart()) { if (!queryParameters.isEmpty()) { - String href = location.href; - String newUrl; - if (href.contains("?")) { - newUrl = href.substring(0, - href.indexOf("?")); - if (startRoute != null) { - if (!startRoute.isEmpty()) { - newUrl = newUrl + "#" + startRoute; + String newUrl = null; + if (startRoute != null) { + if (location.href.contains("?")) { + if (PropertyFactory.INSTANCE.isUsingHash()) { + newUrl = location.origin + location.pathname + "#" + startRoute; + } else { + newUrl = location.origin + "/" + startRoute; } } DomGlobal.window.history.replaceState(newUrl, @@ -175,8 +174,6 @@ public static void addPopStateHandler(RouteChangeHandler handler, if (Objects.isNull(newUrl) || newUrl.trim() .isEmpty()) { - // newUrl = PropertyFactory.INSTANCE - // .getStartRoute(); return null; } }