config-loader: normalize data paths to ensure consistent behavior
This commit is contained in:
@@ -56,7 +56,11 @@ export function compileConfigSchemas(
|
||||
return false;
|
||||
}
|
||||
if (visibility) {
|
||||
visibilityByPath.set(dataPath, visibility);
|
||||
const normalizedPath = dataPath.replace(
|
||||
/\['?(.*?)'?\]/g,
|
||||
(_, segment) => `.${segment}`,
|
||||
);
|
||||
visibilityByPath.set(normalizedPath, visibility);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -40,18 +40,18 @@ const data = {
|
||||
|
||||
const visiblity = new Map<string, ConfigVisibility>(
|
||||
Object.entries({
|
||||
'.arr[0]': 'frontend',
|
||||
'.arr[1]': 'backend',
|
||||
'.arr[2]': 'secret',
|
||||
'.arr.0': 'frontend',
|
||||
'.arr.1': 'backend',
|
||||
'.arr.2': 'secret',
|
||||
'.obj.f': 'frontend',
|
||||
'.obj.b': 'backend',
|
||||
'.obj.b.s': 'secret',
|
||||
'.objArr[0].f': 'frontend',
|
||||
'.objArr[0].b': 'backend',
|
||||
'.objArr[0].s': 'secret',
|
||||
'.objArr[1].f': 'frontend',
|
||||
'.objArr[1].b': 'backend',
|
||||
'.objArr[1].s': 'secret',
|
||||
'.objArr.0.f': 'frontend',
|
||||
'.objArr.0.b': 'backend',
|
||||
'.objArr.0.s': 'secret',
|
||||
'.objArr.1.f': 'frontend',
|
||||
'.objArr.1.b': 'backend',
|
||||
'.objArr.1.s': 'secret',
|
||||
'.arrF': 'frontend',
|
||||
'.arrB': 'backend',
|
||||
'.arrS': 'secret',
|
||||
|
||||
@@ -49,7 +49,7 @@ export function filterByVisibility(
|
||||
const arr = new Array<JsonValue>();
|
||||
|
||||
for (const [index, value] of jsonVal.entries()) {
|
||||
const out = transform(value, `${path}[${index}]`);
|
||||
const out = transform(value, `${path}.${index}`);
|
||||
if (out !== undefined) {
|
||||
arr.push(out);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user