Skip to content

Commit

Permalink
🐛 (bot) Still parse variable ID in code if has no value
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 14, 2023
1 parent 97e2578 commit 17020c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions apps/viewer/src/features/variables/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ export const parseVariables =
if (!text || text === '') return ''
return text.replace(/\{\{(.*?)\}\}/g, (_, fullVariableString) => {
const matchedVarName = fullVariableString.replace(/{{|}}/g, '')
const variable = variables.find((v) => {
return matchedVarName === v.name && isDefined(v.value)
const variable = variables.find((variable) => {
return (
matchedVarName === variable.name &&
(options.fieldToParse === 'id' || isDefined(variable.value))
)
}) as VariableWithValue | undefined
if (!variable || variable.value === null) return ''
if (!variable) return ''
if (options.fieldToParse === 'id') return variable.id
const { value } = variable
if (options.escapeForJson) return jsonParse(value)
Expand Down
9 changes: 6 additions & 3 deletions packages/bot-engine/src/features/variables/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ export const parseVariables =
if (!text || text === '') return ''
return text.replace(/\{\{(.*?)\}\}/g, (_, fullVariableString) => {
const matchedVarName = fullVariableString.replace(/{{|}}/g, '')
const variable = variables.find((v) => {
return matchedVarName === v.name && isDefined(v.value)
const variable = variables.find((variable) => {
return (
matchedVarName === variable.name &&
(options.fieldToParse === 'id' || isDefined(variable.value))
)
}) as VariableWithValue | undefined
if (!variable || variable.value === null) return ''
if (!variable) return ''
if (options.fieldToParse === 'id') return variable.id
const { value } = variable
if (options.escapeForJson) return jsonParse(value)
Expand Down

0 comments on commit 17020c8

Please sign in to comment.