diff options
author | Ed Tanous <edtanous@google.com> | 2022-08-19 17:00:38 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2022-08-24 00:47:32 +0300 |
commit | 7f8d8fa938f521d18278e9cb5673bacd83217d09 (patch) | |
tree | 5134ef203f9db67ce142c18fbc23bc22899697ef /http/ut | |
parent | a3526fee27da0e324cd022ea77d282d1146b3317 (diff) | |
download | bmcweb-7f8d8fa938f521d18278e9cb5673bacd83217d09.tar.xz |
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
Diffstat (limited to 'http/ut')
-rw-r--r-- | http/ut/utility_test.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
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) |