* Fix #593: don't prevent default on link click * Use absolute/explicit path for settings Trying to test fix for #594 * Broken: replace almost all relative URLs with absolute * add relative jump backs util * dot dot slash everywhere * use usLocation not window.location * the one that got away * fmt 🤦♂️ --------- Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
14 lines
468 B
TypeScript
14 lines
468 B
TypeScript
import { useLocation } from 'react-router-dom'
|
|
|
|
export function useDotDotSlash(): (count?: number) => string {
|
|
const location = useLocation()
|
|
const dotDotSlash = (count = 1): string => {
|
|
// since we can't use relative paths (../) for windows
|
|
if (location.pathname === '/') return ''
|
|
const path = location.pathname.slice(0, location.pathname.lastIndexOf('/'))
|
|
if (count <= 1) return path
|
|
return dotDotSlash(count - 1)
|
|
}
|
|
return dotDotSlash
|
|
}
|