Adding a JSON parse incase the input is actually an array in the form of a string (HBS).

This commit is contained in:
Michael Drury 2023-06-01 12:14:34 +01:00
parent cde4dabe42
commit 67588f1051
1 changed files with 9 additions and 1 deletions

View File

@ -44,10 +44,18 @@ function getLoopIterations(loopStep: LoopStep) {
if (!binding) {
return 0
}
const isString = typeof binding === "string"
try {
if (isString) {
binding = JSON.parse(binding)
}
} catch (err) {
// ignore error - wasn't able to parse
}
if (Array.isArray(binding)) {
return binding.length
}
if (typeof binding === "string") {
if (isString) {
return automationUtils.stringSplit(binding).length
}
return 0