Skip to content

Commit aa8e404

Browse files
CarlosEduRanonrig
andauthored
Fix error with pathname (#978)
* test: update web platform tests * update consume_prepared_path and parse_prepared_path, if it's a double dot path segment, ignore if it's shorten path or special * update tests to align with last changes --------- Co-authored-by: anonrig <[email protected]>
1 parent dd38444 commit aa8e404

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

src/helpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,8 @@ ada_really_inline void parse_prepared_path(std::string_view input,
779779
? path_buffer_tmp
780780
: path_view;
781781
if (unicode::is_double_dot_path_segment(path_buffer)) {
782-
if ((helpers::shorten_path(path, type) || special) &&
783-
location == std::string_view::npos) {
782+
helpers::shorten_path(path, type);
783+
if (location == std::string_view::npos) {
784784
path += '/';
785785
}
786786
} else if (unicode::is_single_dot_path_segment(path_buffer) &&

src/url_aggregator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,8 +1563,8 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
15631563
? path_buffer_tmp
15641564
: path_view;
15651565
if (unicode::is_double_dot_path_segment(path_buffer)) {
1566-
if ((helpers::shorten_path(path, type) || special) &&
1567-
location == std::string_view::npos) {
1566+
helpers::shorten_path(path, type);
1567+
if (location == std::string_view::npos) {
15681568
path += '/';
15691569
}
15701570
} else if (unicode::is_single_dot_path_segment(path_buffer) &&

tests/basic_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ TYPED_TEST(basic_tests, node_issue_47889) {
375375
auto url = ada::parse<TypeParam>("..#", &*urlbase);
376376
ASSERT_TRUE(url);
377377
ASSERT_TRUE(url->has_opaque_path);
378-
ASSERT_EQ(url->get_href(), "a:b#");
379-
ASSERT_EQ(url->get_pathname(), "b");
378+
ASSERT_EQ(url->get_href(), "a:b/#");
379+
ASSERT_EQ(url->get_pathname(), "b/");
380380
SUCCEED();
381381
}
382382

tests/wpt/ada_extra_urltestdata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@
274274
{
275275
"input": "..#",
276276
"base": "a:b",
277-
"href": "a:b#",
277+
"href": "a:b/#",
278278
"origin": null,
279279
"protocol": "a:",
280280
"username": "",
281281
"password": "",
282282
"host": "",
283283
"hostname": "",
284284
"port": "",
285-
"pathname": "b",
285+
"pathname": "b/",
286286
"search": "",
287287
"hash": ""
288288
}

tests/wpt/setters_tests.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,14 @@
22142214
"href": "http://example.net/%00",
22152215
"pathname": "/%00"
22162216
}
2217+
},
2218+
{
2219+
"href": "foo://path/to",
2220+
"new_value": "/..",
2221+
"expected": {
2222+
"href": "foo://path/",
2223+
"pathname": "/"
2224+
}
22172225
}
22182226
],
22192227
"search": [

0 commit comments

Comments
 (0)