Skip to content

Commit

Permalink
Added slash to url
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Nov 14, 2024
1 parent 358c47b commit efb8e31
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions components/h5web/h5web.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useLocation, useSearchParams } from "react-router-dom";

// eslint-disable-next-line react/prop-types
export default function H5web({ domain }) {

let [searchParams, setSearchParams] = useSearchParams();
const location = useLocation();

Expand All @@ -15,16 +14,20 @@ export default function H5web({ domain }) {

const initialPathParams = searchParams.get("initialPath");

const [hash, useHash] = useState(decodeURIComponent(window.location.hash.substring(1)))

const [hash, useHash] = useState(
decodeURIComponent(window.location.hash.substring(1))
);

const initialPath = initialPathParams ? initialPathParams :
hash ? hash : '/'
const initialPath = initialPathParams ? initialPathParams : hash ? hash : "/";

const downloadFile = () => {
fetch(`${import.meta.env.VITE_BaseURL}db/download?what=h5&domain=${domain ? domain : h5webParams}`)
.then(resp => resp.blob())
.then(blob => {
fetch(
`${import.meta.env.VITE_BaseURL}db/download?what=h5&domain=${
domain ? domain : h5webParams
}`
)
.then((resp) => resp.blob())
.then((blob) => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
Expand All @@ -33,22 +36,18 @@ export default function H5web({ domain }) {
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);

})
.catch(() => alert("Failed to download the file!"));
}
};

return (
<div>
<div className="downloadBtn">
<button
className="shareBtn"
onClick={() => downloadFile()}
>
<button className="shareBtn" onClick={() => downloadFile()}>
Download the file
</button>
</div>
<div style={{height: "100vh"}}>
<div style={{ height: "100vh" }}>
<HsdsProvider
url="https://hsds-kc.ideaconsult.net"
username="system-public-user"
Expand Down
2 changes: 1 addition & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const router = createBrowserRouter(
Component: App,
},
],
{ basename: "/search" }
{ basename: "/search/" }
);

ReactDOM.createRoot(document.getElementById("root")).render(
Expand Down

0 comments on commit efb8e31

Please sign in to comment.