Skip to content

Commit

Permalink
Bugfix/get rid of double quotes when replacing variable value (Flowis…
Browse files Browse the repository at this point in the history
…eAI#2577)

get rid of double quotes when replacing variable value
  • Loading branch information
HenryHengZJ authored Jun 4, 2024
1 parent 5ba9493 commit 4ec8376
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,13 @@ export const getVariableValue = (
const variableValue = variableDict[path]
// Replace all occurrence
if (typeof variableValue === 'object') {
returnVal = returnVal.split(path).join(JSON.stringify(JSON.stringify(variableValue)))
const stringifiedValue = JSON.stringify(JSON.stringify(variableValue))
if (stringifiedValue.startsWith('"') && stringifiedValue.endsWith('"')) {
// get rid of the double quotes
returnVal = returnVal.split(path).join(stringifiedValue.substring(1, stringifiedValue.length - 1))
} else {
returnVal = returnVal.split(path).join(JSON.stringify(variableValue).replace(/"/g, '\\"'))
}
} else {
returnVal = returnVal.split(path).join(variableValue)
}
Expand Down

0 comments on commit 4ec8376

Please sign in to comment.