10 lines
272 B
TypeScript
10 lines
272 B
TypeScript
|
|
export const validateRedirect = (redirect: string | unknown, fallback = '/dashboard'): string => {
|
||
|
|
if (typeof redirect !== 'string') {
|
||
|
|
return fallback;
|
||
|
|
}
|
||
|
|
if (redirect.startsWith('/') && !redirect.startsWith('//')) {
|
||
|
|
return redirect;
|
||
|
|
}
|
||
|
|
return fallback;
|
||
|
|
}
|