// Where to land after auth. The router guard stashes the intended destination // in ?redirect=, and the login page reads it back; both go through this so a // caller-controlled value can never send the user to an external origin. const DEFAULT_DESTINATION = '/gardens' /** * Return dest only if it is a same-origin absolute path (starts with a single * '/'); otherwise fall back to the gardens list. Rejects protocol-relative * ('//evil.com') and absolute ('https://…') URLs. */ export function safeRedirectPath(dest: string | undefined, fallback = DEFAULT_DESTINATION): string { return dest && dest.startsWith('/') && !dest.startsWith('//') ? dest : fallback }