Allow parsing urls with extra elements
Sometimes it is desirable to only parse a portion of a URL, and allow
any elements at the end. This comes up significantly in aggregation
where parsing "/redfish/v1/<collection>/anything is pretty common.
This commit adds a new class, OrMorePaths, that can be used as a
placeholder to indicate that more paths should be accepted.
Tested: Unit tests pass.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: If4fb3991a91560fd3b8b838f912aa36e79ddd2b3
diff --git a/http/ut/utility_test.cpp b/http/ut/utility_test.cpp
index 4d9bd91..8eef93f 100644
--- a/http/ut/utility_test.cpp
+++ b/http/ut/utility_test.cpp
@@ -147,6 +147,12 @@
parsed = boost::urls::parse_relative_ref("not/absolute/url");
EXPECT_FALSE(readUrlSegments(*parsed, "not", "absolute", "url"));
+
+ parsed = boost::urls::parse_relative_ref("/excellent/path");
+
+ EXPECT_TRUE(readUrlSegments(*parsed, "excellent", "path", OrMorePaths()));
+ EXPECT_TRUE(readUrlSegments(*parsed, "excellent", OrMorePaths()));
+ EXPECT_TRUE(readUrlSegments(*parsed, OrMorePaths()));
}
TEST(Utility, ValidateAndSplitUrlPositive)