Get rid of empty segments in config path

This commit is contained in:
Mike Bierlee 2022-09-24 03:32:30 +03:00
parent 70301442a2
commit 7d7dd9a328

View file

@ -113,7 +113,12 @@ class ConfigPath {
this(const string path) {
this.path = path;
this.segments = path.split(".");
foreach (segment; path.split(".")) {
if (segment.length > 0) {
segments ~= segment;
}
}
}
PathSegment getNextSegment() {
@ -407,4 +412,15 @@ version (unittest) {
assert(dictionary.get("tres.thisone") == "three");
}
@("Ignore empty segments")
unittest {
auto dictionary = new ConfigDictionary();
dictionary.rootNode = new ObjectNode(
[
"one": new ObjectNode(["two": new ObjectNode(["three": "four"])])
]);
assert(dictionary.get(".one..two...three....") == "four");
}
}