From 4e99db7d426cf516daf0bde79c883d1f22960205 Mon Sep 17 00:00:00 2001 From: sergesoroka Date: Tue, 3 Sep 2024 10:28:13 +0200 Subject: [PATCH] Using a Query Fragment as initialPath --- components/h5web/h5web.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/components/h5web/h5web.jsx b/components/h5web/h5web.jsx index 2d8f7e6..eeb0dad 100755 --- a/components/h5web/h5web.jsx +++ b/components/h5web/h5web.jsx @@ -1,7 +1,8 @@ import "@h5web/app/dist/styles.css"; import { App, HsdsProvider } from "@h5web/app"; -import { useLocation, useSearchParams } from "react-router-dom"; +import { useLocation, useSearchParams, useParams } from "react-router-dom"; +import { useState } from "react"; // eslint-disable-next-line react/prop-types export default function H5web({ domain }) { @@ -12,7 +13,14 @@ export default function H5web({ domain }) { const queryParams = new URLSearchParams(location.search); const h5webParams = queryParams.get("h5web"); - const initialPathParams = searchParams.get("initialPath") + const initialPathParams = searchParams.get("initialPath"); + + const [hash, useHash] = useState(decodeURIComponent(window.location.hash.substring(1))) + + + const initialPath = initialPathParams ? initialPathParams : + hash ? hash : '/' + return ( @@ -24,7 +32,7 @@ export default function H5web({ domain }) { password="system-public-user" filepath={`${domain ? domain : h5webParams}`} > - +