From 7d7dd9a32895ba2b32dbeddbe6b8098c73f6c8d8 Mon Sep 17 00:00:00 2001 From: Mike Bierlee Date: Sat, 24 Sep 2022 03:32:30 +0300 Subject: [PATCH] Get rid of empty segments in config path --- source/poodinis/config/dictionary.d | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/poodinis/config/dictionary.d b/source/poodinis/config/dictionary.d index b222776..826d775 100644 --- a/source/poodinis/config/dictionary.d +++ b/source/poodinis/config/dictionary.d @@ -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"); + } + }