This commit is contained in:
Ruben Fiszel
2023-04-24 00:16:56 +02:00
committed by GitHub
parent 0d21bf8ca5
commit abd1fd5aa0
2 changed files with 6 additions and 16 deletions
@@ -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<T>(newValue, realPath)
} else {
value = newValue
+1 -6
View File
@@ -81,12 +81,7 @@ export function schemaToInputsSpec(
}, {})
}
export function accessPropertyByPath<T>(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<T>(object: T, path: string): any {
let a = path.split('.')
for (let i = 0, depth = a.length; i < depth; ++i) {