mirror of
https://github.com/mbierlee/mirage-config.git
synced 2024-11-15 04:44:01 +01:00
Get rid of empty segments in config path
This commit is contained in:
parent
70301442a2
commit
7d7dd9a328
|
@ -113,7 +113,12 @@ class ConfigPath {
|
||||||
|
|
||||||
this(const string path) {
|
this(const string path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.segments = path.split(".");
|
|
||||||
|
foreach (segment; path.split(".")) {
|
||||||
|
if (segment.length > 0) {
|
||||||
|
segments ~= segment;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PathSegment getNextSegment() {
|
PathSegment getNextSegment() {
|
||||||
|
@ -407,4 +412,15 @@ version (unittest) {
|
||||||
assert(dictionary.get("tres.thisone") == "three");
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue