Skip to content

Commit 3c43bab

Browse files
authored
path setter bug (#659)
* path setter bug * fix: compare // with pathname, not input
1 parent 2e46628 commit 3c43bab

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/url_aggregator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ bool url_aggregator::set_pathname(const std::string_view input) {
317317
}
318318
clear_pathname();
319319
parse_path(input);
320-
if (checkers::begins_with(input, "//") && !has_authority() &&
320+
if (checkers::begins_with(get_pathname(), "//") && !has_authority() &&
321321
!has_dash_dot()) {
322322
buffer.insert(components.pathname_start, "/.");
323323
components.pathname_start += 2;

tests/basic_tests.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,14 @@ TYPED_TEST(basic_tests, nodejs_undici_2971) {
430430
out->get_href(),
431431
R"(https://non-ascii-location-header.sys.workers.dev/%EC%95%88%EB%85%95)");
432432
SUCCEED();
433+
}
434+
435+
TYPED_TEST(basic_tests, path_setter_bug) {
436+
std::string_view base = "blob:/?";
437+
auto base_url = ada::parse<ada::url_aggregator>(base);
438+
ASSERT_TRUE(base_url);
439+
ASSERT_TRUE(base_url->validate());
440+
ASSERT_TRUE(base_url->set_pathname("//.."));
441+
ASSERT_TRUE(base_url->validate());
442+
SUCCEED();
433443
}

0 commit comments

Comments
 (0)