mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-28 04:36:43 -05:00
2e64b0d54f
Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
25 lines
777 B
TypeScript
25 lines
777 B
TypeScript
import { TActionClassPageUrlRule } from "@formbricks/types/actionClasses";
|
|
|
|
export const testURLmatch = (
|
|
testUrl: string,
|
|
pageUrlValue: string,
|
|
pageUrlRule: TActionClassPageUrlRule
|
|
): 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");
|
|
}
|
|
};
|