mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-04 09:29:42 -06:00
21 lines
788 B
TypeScript
21 lines
788 B
TypeScript
export type MatchType = "exactMatch" | "contains" | "startsWith" | "endsWith" | "notMatch" | "notContains";
|
|
|
|
export const testURLmatch = (testUrl: string, pageUrlValue: string, pageUrlRule: MatchType): string => {
|
|
switch (pageUrlRule) {
|
|
case "exactMatch":
|
|
return testUrl === pageUrlValue ? "yes" : "no";
|
|
case "contains":
|
|
return testUrl.includes(pageUrlValue) ? "yes" : "no";
|
|
case "startsWith":
|
|
return testUrl.startsWith(pageUrlValue) ? "yes" : "no";
|
|
case "endsWith":
|
|
return testUrl.endsWith(pageUrlValue) ? "yes" : "no";
|
|
case "notMatch":
|
|
return testUrl !== pageUrlValue ? "yes" : "no";
|
|
case "notContains":
|
|
return !testUrl.includes(pageUrlValue) ? "yes" : "no";
|
|
default:
|
|
throw new Error("Invalid match type");
|
|
}
|
|
};
|