You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/AzureAppConfigurationImpl.ts
+7-2Lines changed: 7 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -203,12 +203,17 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
203
203
}
204
204
// The path has been occupied by a non-object value, causing ambiguity.
205
205
if(typeofcurrent[segment]!=="object"){
206
-
thrownewError(`The key '${segments.slice(0,i+1).join(separator)}' is not a valid path.`);
206
+
thrownewError(`Ambiguity occurs when constructing configuration object from key '${key}', value '${value}'. The path '${segments.slice(0,i+1).join(separator)}' has been occupied.`);
207
207
}
208
208
current=current[segment];
209
209
}
210
+
211
+
constlastSegment=segments[segments.length-1];
212
+
if(current[lastSegment]!==undefined){
213
+
thrownewError(`Ambiguity occurs when constructing configuration object from key '${key}', value '${value}'. The key should not be part of another key.`);
@@ -243,7 +249,28 @@ describe("load", function () {
243
249
expect(settings).not.undefined;
244
250
expect(()=>{
245
251
settings.constructConfigurationObject();
246
-
}).to.throw("The key 'app3.settings' is not a valid path.");
252
+
}).to.throw("Ambiguity occurs when constructing configuration object from key 'app3.settings.fontColor', value 'yellow'. The path 'app3.settings' has been occupied.");
253
+
});
254
+
255
+
/**
256
+
* Edge case: Hierarchical key-value pairs with overlapped key prefix.
}).to.throw("Ambiguity occurs when constructing configuration object from key 'app5.settings', value 'placeholder'. The key should not be part of another key.");
247
274
});
248
275
249
276
it("should construct configuration object with array",async()=>{
0 commit comments