Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL: trailing spaces always get removed from opaque paths #51129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions url/resources/setters_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -2192,15 +2192,15 @@
"href": "data:space ?query#fragment",
"new_value": "",
"expected": {
"href": "data:space #fragment",
"href": "data:space#fragment",
"search": ""
}
},
{
"href": "sc:space ?query#fragment",
"new_value": "",
"expected": {
"href": "sc:space #fragment",
"href": "sc:space#fragment",
"search": ""
}
},
Expand Down Expand Up @@ -2357,7 +2357,7 @@
}
},
{
"comment": "Drop trailing spaces from trailing opaque paths",
"comment": "Drop trailing spaces from opaque paths",
"href": "data:space #fragment",
"new_value": "",
"expected": {
Expand All @@ -2376,19 +2376,19 @@
}
},
{
"comment": "Do not drop trailing spaces from non-trailing opaque paths",
"comment": "Drop trailing spaces from opaque paths",
"href": "data:space ?query#fragment",
"new_value": "",
"expected": {
"href": "data:space ?query",
"href": "data:space?query",
"hash": ""
}
},
{
"href": "sc:space ?query#fragment",
"new_value": "",
"expected": {
"href": "sc:space ?query",
"href": "sc:space?query",
"hash": ""
}
},
Expand Down
75 changes: 75 additions & 0 deletions url/resources/urltestdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3778,6 +3778,81 @@
"search": "",
"hash": ""
},
{
"input": "non-special:opaque ",
"base": null,
"href": "non-special:opaque",
"origin": "null",
"protocol": "non-special:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "opaque",
"search": "",
"hash": ""
},
{
"input": "non-special:opaque ?hi",
"base": null,
"href": "non-special:opaque?hi",
"origin": "null",
"protocol": "non-special:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "opaque",
"search": "?hi",
"hash": ""
},
{
"input": "non-special:opaque #hi",
"base": null,
"href": "non-special:opaque#hi",
"origin": "null",
"protocol": "non-special:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "opaque",
"search": "",
"hash": "#hi"
},
Comment on lines +3782 to +3825
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to add a copy of these with a trailing %20 (which should not be stripped)

{
"input": "non-special:opaque x?hi",
"base": null,
"href": "non-special:opaque x?hi",
"origin": "null",
"protocol": "non-special:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "opaque x",
"search": "?hi",
"hash": ""
},
{
"input": "non-special:opaque x#hi",
"base": null,
"href": "non-special:opaque x#hi",
"origin": "null",
"protocol": "non-special:",
"username": "",
"password": "",
"host": "",
"hostname": "",
"port": "",
"pathname": "opaque x",
"search": "",
"hash": "#hi"
},
"Ideographic full stop (full-width period for Chinese, etc.) should be treated as a dot. U+3002 is mapped to U+002E (dot)",
{
"input": "http://www.foo。bar.com",
Expand Down
8 changes: 4 additions & 4 deletions url/urlsearchparams-delete.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ test(() => {
assert_equals(url.search, '');
assert_equals(url.pathname, 'space');
assert_equals(url.href, 'data:space');
}, 'Changing the query of a URL with an opaque path can impact the path');
}, 'Changing the query of a URL with an opaque path with trailing spaces');

test(() => {
const url = new URL('data:space ?test#test');
url.searchParams.delete('test');
assert_equals(url.search, '');
assert_equals(url.pathname, 'space ');
assert_equals(url.href, 'data:space #test');
}, 'Changing the query of a URL with an opaque path can impact the path if the URL has no fragment');
assert_equals(url.pathname, 'space');
assert_equals(url.href, 'data:space#test');
}, 'Changing the query of a URL with an opaque path with trailing spaces and a fragment');

test(() => {
const params = new URLSearchParams();
Expand Down