mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-25 21:01:54 +08:00
🐛 Improve invalid regex handling in comparison logic
This commit is contained in:
parent
45f7e2ca5e
commit
78a1ce26f9
@ -12,7 +12,7 @@ export const executeCondition = (
|
||||
sessionStore,
|
||||
variables,
|
||||
}: { sessionStore: SessionStore; variables: Variable[] },
|
||||
): boolean => {
|
||||
): { passed: boolean; logs?: ContinueChatResponse["logs"] } => {
|
||||
if (!condition.comparisons || condition.comparisons.length === 0)
|
||||
return false;
|
||||
return (condition.logicalOperator ?? LogicalOperator.AND) ===
|
||||
@ -178,7 +178,12 @@ const executeComparison = (
|
||||
if (b === "" || !b || !a) return false;
|
||||
const regex = preprocessRegex(b);
|
||||
if (!regex.pattern) return false;
|
||||
return new RegExp(regex.pattern, regex.flags).test(a);
|
||||
try {
|
||||
return new RegExp(regex.pattern, regex.flags).test(a);
|
||||
} catch {
|
||||
// Most likelInvalid regex, treat as non-match
|
||||
return false;
|
||||
}
|
||||
};
|
||||
return compare(matchesRegex, inputValue, value, "some");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user