diff --git a/frontend/src/lib/components/apps/components/helpers/InputValue.svelte b/frontend/src/lib/components/apps/components/helpers/InputValue.svelte index 37ee0758d5..872fc79956 100644 --- a/frontend/src/lib/components/apps/components/helpers/InputValue.svelte +++ b/frontend/src/lib/components/apps/components/helpers/InputValue.svelte @@ -142,17 +142,12 @@ return } - const { path } = connection - - const hasSubPath = ['.', '['].some((x) => path.includes(x)) - - if (hasSubPath) { - const realPath = path - .replace(/\[(\w+)\]/g, '.$1') - .split('.') - .slice(1) - .join('.') + let { path }: { path: string } = connection + path = path.replace(/\[(\d+)\]/g, '.$1').replace(/\[\"(.*)\"\]/g, '.$1') + let splitPoint = path.indexOf('.') + if (splitPoint != -1) { + const realPath = path.substring(splitPoint + 1) value = accessPropertyByPath(newValue, realPath) } else { value = newValue diff --git a/frontend/src/lib/components/apps/utils.ts b/frontend/src/lib/components/apps/utils.ts index cbb75e8739..4c27c586ae 100644 --- a/frontend/src/lib/components/apps/utils.ts +++ b/frontend/src/lib/components/apps/utils.ts @@ -81,12 +81,7 @@ export function schemaToInputsSpec( }, {}) } -export function accessPropertyByPath(object: T, path: string): T | undefined { - // convert indexes to properties - path = path.replace(/\[(\w+)\]/g, '.$1') - // strip a leading dot - path = path.replace(/^\./, '') - +export function accessPropertyByPath(object: T, path: string): any { let a = path.split('.') for (let i = 0, depth = a.length; i < depth; ++i) {