Skip to content

Commit

Permalink
fix(engine): 🚸 Return empty string if evaluated JS is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Mar 7, 2022
1 parent fd9c19a commit 0710403
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/bot-engine/src/services/variable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Variable } from 'models'
import { isDefined } from 'utils'
import { isDefined, isNotDefined } from 'utils'

const safeEval = eval

Expand All @@ -23,8 +23,9 @@ export const parseVariables =
export const evaluateExpression = (str: string) => {
try {
const evaluatedResult = safeEval(str)
return evaluatedResult.toString()
return isNotDefined(evaluatedResult) ? '' : evaluatedResult.toString()
} catch (err) {
console.log(err)
return str
}
}
Expand Down

2 comments on commit 0710403

@vercel
Copy link

@vercel vercel bot commented on 0710403 Mar 7, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 0710403 Mar 7, 2022

Please sign in to comment.