From 7f8d8fa938f521d18278e9cb5673bacd83217d09 Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Fri, 19 Aug 2022 07:00:38 -0700 Subject: 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//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 Change-Id: If4fb3991a91560fd3b8b838f912aa36e79ddd2b3 --- http/ut/utility_test.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'http/ut') diff --git a/http/ut/utility_test.cpp b/http/ut/utility_test.cpp index 4d9bd91105..8eef93f4a3 100644 --- a/http/ut/utility_test.cpp +++ b/http/ut/utility_test.cpp @@ -147,6 +147,12 @@ TEST(Utility, readUrlSegments) 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) -- cgit v1.2.3