Fix StaticSchema::lastNodeOfSchemaPath
This if branch was never used in any test, so the bug never came up.
Change-Id: I785600076df8aea7d8169b020d0bda65f5b74ae4
diff --git a/src/static_schema.cpp b/src/static_schema.cpp
index 4964e8e..3eb42f6 100644
--- a/src/static_schema.cpp
+++ b/src/static_schema.cpp
@@ -116,17 +116,9 @@
std::string lastNodeOfSchemaPath(const std::string& path)
{
std::string res = path;
- auto pos = res.find_last_of('/');
- if (pos == 0) { // path had only one path fragment - "/something:something"
- res.erase(0, 1);
- return res;
+ if (auto pos = res.find_last_of('/'); pos != res.npos) {
+ res.erase(0, pos + 1);
}
- if (pos != res.npos) { // path had more fragments
- res.erase(0, pos);
- return res;
- }
-
- // path was empty
return res;
}