splitwise / src /lib /server /auth /decode-path.ts
assafvayner's picture
assafvayner HF Staff
fix(auth): gate admin routes on the decoded path and in the actions themselves
857fbc2
Raw
History Blame Contribute Delete
354 Bytes
/**
* Decode a URL pathname the way SvelteKit does before matching routes: every
* segment between literal `%25` sequences is decoded, so `/%61dmin` becomes
* `/admin`. Throws `URIError` on a malformed escape sequence.
*/
export function decodePathname(pathname: string): string {
return pathname.split('%25').map(decodeURIComponent).join('%25');
}