mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 14:39:29 +02:00
18 lines
535 B
TypeScript
18 lines
535 B
TypeScript
type PatternConfig = {
|
|
name: string;
|
|
regex: RegExp;
|
|
};
|
|
|
|
const patterns: PatternConfig[] = [
|
|
{ name: "Invite Token", regex: /^\/invite\?token=[a-zA-Z0-9-]+$/ },
|
|
{ name: "Setup", regex: /^\/setup$/ },
|
|
{ name: "Resource Auth Portal", regex: /^\/auth\/resource\/\d+$/ }
|
|
];
|
|
|
|
export function cleanRedirect(input: string): string {
|
|
if (!input || typeof input !== "string") {
|
|
return "/";
|
|
}
|
|
const isAccepted = patterns.some((pattern) => pattern.regex.test(input));
|
|
return isAccepted ? input : "/";
|
|
}
|