From 9794852d3f0e1671c88ff38d8aa7fdcc292bdb7a Mon Sep 17 00:00:00 2001 From: Le Vivilet Date: Thu, 19 Feb 2026 00:00:19 +0100 Subject: [PATCH] feature: refactor setPathName to use matchesPathName for path comparison --- .../src/parts/Location/Location.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/renderer-process/src/parts/Location/Location.ts b/packages/renderer-process/src/parts/Location/Location.ts index 60a4c0b2..03cd42d2 100644 --- a/packages/renderer-process/src/parts/Location/Location.ts +++ b/packages/renderer-process/src/parts/Location/Location.ts @@ -10,10 +10,23 @@ export const getHref = () => { return location.href } +const matchesPathName = (a: string, b: string) => { + if (a === b) { + return true + } + if (a === '/' && b === '') { + return true + } + if (a === '' && b === '/') { + return true + } + return false +} + // TODO should do nothing if it is already at this path export const setPathName = (pathName) => { const currentPathName = getPathName() - if (currentPathName === pathName) { + if (matchesPathName(currentPathName, pathName)) { return } // @ts-expect-error