Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/flow-spec/IBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,14 @@ export function createEvalContactFrom(contact: IContact): IContact {
}

export function evaluateToBool(expr: string, ctx: object): boolean {
return JSON.parse(evaluateToString(expr, ctx).toLowerCase())
const result = evaluateToString(expr, ctx).toLowerCase().trim()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a measurable performance impact in making this change, and if so, what is that measurement?

if (result === 'true') {
return true
}
if (result === 'false') {
return false
}
throw new ValidationException(`Expression "${expr} does not evaluate to bool: ${result}"`)
}

export function evaluateToString(expr: string, ctx: object): string {
Expand Down