2
0

fix(engine): 🚸 Return empty string if evaluated JS is not defined

This commit is contained in:
Baptiste Arnaud
2022-03-07 09:48:10 +01:00
parent fd9c19a4c2
commit 07104038c4

View File

@ -1,5 +1,5 @@
import { Variable } from 'models'
import { isDefined } from 'utils'
import { isDefined, isNotDefined } from 'utils'
const safeEval = eval
@ -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
}
}