Skip to content
Snippets Groups Projects
Commit c6dcc946 authored by kPherox's avatar kPherox Committed by Angelina Filippova
Browse files

Fix parsing objects in config

parent 5670be0e
No related branches found
No related tags found
No related merge requests found
......@@ -107,8 +107,14 @@ export const parseTuples = (tuples, key) => {
nonAtomsTuples.includes(item.tuple[0])
? accum[item.tuple[0].substr(1)] = parseNonAtomTuples(item.tuple[1])
: accum[item.tuple[0].substr(1)] = parseTuples(item.tuple[1])
} else if (Array.isArray(item.tuple[1])) {
accum[item.tuple[0].substr(1)] = item.tuple[1]
} else if (item.tuple[1] && typeof item.tuple[1] === 'object' && 'tuple' in item.tuple[1]) {
accum[item.tuple[0].substr(1)] = item.tuple[1]['tuple'].join('.')
} else if (item.tuple[1] && typeof item.tuple[1] === 'object') {
nonAtomsObjects.includes(item.tuple[0])
? accum[item.tuple[0].substr(1)] = parseNonAtomObject(item.tuple[1])
: accum[item.tuple[0].substr(1)] = parseObject(item.tuple[1])
} else {
key === 'mrf_user_allowlist'
? accum[item.tuple[0]] = item.tuple[1]
......@@ -125,6 +131,20 @@ const parseNonAtomTuples = (tuples) => {
}, {})
}
const parseNonAtomObject = (object) => {
return Object.keys(object).reduce((acc, item) => {
acc[item] = object[item]
return acc
}, {})
}
const parseObject = (object) => {
return Object.keys(object).reduce((acc, item) => {
acc[item.substr(1)] = object[item]
return acc
}, {})
}
export const valueHasTuples = (key, value) => {
const valueIsArrayOfNonObjects = Array.isArray(value) && value.length > 0 && typeof value[0] !== 'object'
return key === 'meta' ||
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment