Fix statically replaced HASH_ROUTING env variables

Also moves the HASH_ROUTING env variable from being modified inside the
hashRouter.spec.ts into the webserver config in the
playwright.config.ipfs.ts

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2023-04-03 11:50:24 +02:00
committed by Rūdolfs Ošiņš
parent 6a03ccef2d
commit 4c3bd7ee04
10 changed files with 45 additions and 33 deletions
+4 -4
View File
@@ -16,7 +16,7 @@ export const activeRouteStore: Readable<Route> = derived(
},
);
export const base = window.HASH_ROUTING ? "./" : "/";
export const base = import.meta.env.VITE_HASH_ROUTING ? "./" : "/";
// Gets triggered when clicking on an anchor hash tag e.g. <a href="#header"/>
// Allows the jump to a anchor hash
@@ -97,7 +97,7 @@ export const push = (newRoute: Route): void => {
// one subsequent pop() anyway.
historyStore.set([...history, newRoute].slice(-10));
const path = window.HASH_ROUTING
const path = import.meta.env.VITE_HASH_ROUTING
? "#" + routeToPath(newRoute)
: routeToPath(newRoute);
@@ -116,7 +116,7 @@ export const pop = (): void => {
export function replace(newRoute: Route): void {
historyStore.set([newRoute]);
const path = window.HASH_ROUTING
const path = import.meta.env.VITE_HASH_ROUTING
? "#" + routeToPath(newRoute)
: routeToPath(newRoute);
@@ -142,7 +142,7 @@ function pathToRoute(path: string): Route | null {
}
const url = new URL(path, window.origin);
const segments = window.HASH_ROUTING
const segments = import.meta.env.VITE_HASH_ROUTING
? url.hash.substring(2).split("#")[0].split("/") // Try to remove any additional hashes at the end of the URL.
: url.pathname.substring(1).split("/");