Files
order_site/apps/frontend/src/utils/worker-routes.ts
T

16 lines
614 B
TypeScript

export function resolveLegacyWorkerPath(hash: string) {
const value = hash.startsWith('#') ? hash.slice(1) : hash
const queryIndex = value.indexOf('?')
const pathname = queryIndex >= 0 ? value.slice(0, queryIndex) : value
const search = queryIndex >= 0 ? value.slice(queryIndex) : ''
if (pathname === '/worker' || pathname === '/worker/' || pathname === '/worker/login') {
return `/${search}`
}
if (pathname === '/worker/hall') return `/hall${search}`
if (pathname === '/worker/orders') return `/orders${search}`
if (pathname === '/worker/profile') return `/profile${search}`
return ''
}