Allow going up with ".." when in root
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/176
Change-Id: I23797edf159d39efe4e58b1d7c560aa3c13117b3
diff --git a/src/parser.cpp b/src/parser.cpp
index ce583ea..4911fac 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -86,10 +86,13 @@
m_curDir = name;
} else {
for (const auto& it : name.m_nodes) {
- if (std::holds_alternative<nodeup_>(it.m_suffix))
- m_curDir.m_nodes.pop_back();
- else
+ if (std::holds_alternative<nodeup_>(it.m_suffix)) {
+ if (!m_curDir.m_nodes.empty()) { // Allow going up, when already at root
+ m_curDir.m_nodes.pop_back();
+ }
+ } else {
m_curDir.m_nodes.push_back(it);
+ }
}
}
}