mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-29 09:50:10 -06:00
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com> Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com> Co-authored-by: Victor Santos <victor@formbricks.com> Co-authored-by: victorvhs017 <115753265+victorvhs017@users.noreply.github.com>
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
export const isLoginRoute = (url: string) => url === "/api/auth/callback/credentials";
|
|
|
|
export const isSignupRoute = (url: string) => url === "/auth/signup";
|
|
|
|
export const isVerifyEmailRoute = (url: string) => url === "/auth/verify-email";
|
|
|
|
export const isForgotPasswordRoute = (url: string) => url === "/auth/forgot-password";
|
|
|
|
export const isClientSideApiRoute = (url: string): boolean => {
|
|
if (url.includes("/api/packages/")) return true;
|
|
if (url.includes("/api/v1/js/actions")) return true;
|
|
if (url.includes("/api/v1/client/storage")) return true;
|
|
const regex = /^\/api\/v\d+\/client\//;
|
|
return regex.test(url);
|
|
};
|
|
|
|
export const isManagementApiRoute = (url: string): boolean => {
|
|
const regex = /^\/api\/v\d+\/management\//;
|
|
return regex.test(url);
|
|
};
|
|
|
|
export const isShareUrlRoute = (url: string): boolean => {
|
|
const regex = /\/share\/[A-Za-z0-9]+\/(?:summary|responses)/;
|
|
return regex.test(url);
|
|
};
|
|
|
|
export const isAuthProtectedRoute = (url: string): boolean => {
|
|
// List of routes that require authentication
|
|
const protectedRoutes = ["/environments", "/setup/organization", "/organizations"];
|
|
|
|
return protectedRoutes.some((route) => url.startsWith(route));
|
|
};
|
|
|
|
export const isSyncWithUserIdentificationEndpoint = (
|
|
url: string
|
|
): { environmentId: string; userId: string } | false => {
|
|
const regex = /\/api\/v1\/client\/(?<environmentId>[^/]+)\/app\/sync\/(?<userId>[^/]+)/;
|
|
const match = url.match(regex);
|
|
return match ? { environmentId: match.groups!.environmentId, userId: match.groups!.userId } : false;
|
|
};
|