Skip to content

Commit

Permalink
Bugfix/variables replacing (#3129)
Browse files Browse the repository at this point in the history
fix variables replacing
  • Loading branch information
HenryHengZJ authored Sep 2, 2024
1 parent 4c1378c commit 66a603f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,15 @@ export const getVariableValue = async (
flowData?: ICommonObject
) => {
const isObject = typeof paramValue === 'object'
let returnVal = (isObject ? JSON.stringify(paramValue) : paramValue) ?? ''
const initialValue = (isObject ? JSON.stringify(paramValue) : paramValue) ?? ''
let returnVal = initialValue
const variableStack = []
const variableDict = {} as IVariableDict
let startIdx = 0
const endIdx = returnVal.length - 1
const endIdx = initialValue.length - 1

while (startIdx < endIdx) {
const substr = returnVal.substring(startIdx, startIdx + 2)
const substr = initialValue.substring(startIdx, startIdx + 2)

// Store the opening double curly bracket
if (substr === '{{') {
Expand All @@ -795,7 +796,7 @@ export const getVariableValue = async (
if (substr === '}}' && variableStack.length > 0 && variableStack[variableStack.length - 1].substr === '{{') {
const variableStartIdx = variableStack[variableStack.length - 1].startIdx
const variableEndIdx = startIdx
const variableFullPath = returnVal.substring(variableStartIdx, variableEndIdx)
const variableFullPath = initialValue.substring(variableStartIdx, variableEndIdx)

/**
* Apply string transformation to convert special chars:
Expand Down

0 comments on commit 66a603f

Please sign in to comment.