Bugfix/get rid of double quotes when replacing variable value (#2577)

get rid of double quotes when replacing variable value
pull/2579/head
Henry Heng 2024-06-04 15:44:27 +01:00 committed by GitHub
parent 5ba9493b30
commit 4ec8376efa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 1 deletions

View File

@ -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)
}