diff --git a/src/libutil-tests/url.cc b/src/libutil-tests/url.cc index 5c7b02248..cd6816096 100644 --- a/src/libutil-tests/url.cc +++ b/src/libutil-tests/url.cc @@ -868,6 +868,12 @@ TEST_P(ParsedURLPathSegmentsTest, segmentsAreCorrect) EXPECT_EQ(encodeUrlPath(segments), testCase.path); } +TEST_P(ParsedURLPathSegmentsTest, to_string) +{ + const auto & testCase = GetParam(); + EXPECT_EQ(testCase.url, parseURL(testCase.url).to_string()); +} + INSTANTIATE_TEST_SUITE_P( ParsedURL, ParsedURLPathSegmentsTest, @@ -886,6 +892,13 @@ INSTANTIATE_TEST_SUITE_P( .skipEmpty = false, .description = "empty_authority_empty_path", }, + ParsedURLPathSegmentsTestCase{ + .url = "path:/", + .segments = {"", ""}, + .path = "/", + .skipEmpty = false, + .description = "empty_authority_root_path", + }, ParsedURLPathSegmentsTestCase{ .url = "scheme:///", .segments = {"", ""}, diff --git a/src/libutil/url.cc b/src/libutil/url.cc index 1c7fd3f0f..a50de0944 100644 --- a/src/libutil/url.cc +++ b/src/libutil/url.cc @@ -350,7 +350,7 @@ std::string ParsedURL::renderAuthorityAndPath() const must either be empty or begin with a slash ("/") character. */ assert(path.empty() || path.front().empty()); res += authority->to_string(); - } else if (std::ranges::equal(std::views::take(path, 2), std::views::repeat("", 2))) { + } else if (std::ranges::equal(std::views::take(path, 3), std::views::repeat("", 3))) { /* If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//") */ unreachable();