Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d55a5e

Browse filesBrowse files
anonriglemire
authored andcommitted
url: fix url spec compliance issues
Co-authored-by: Daniel Lemire <daniel@lemire.me> PR-URL: #46547 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 95bbd0f commit 9d55a5e
Copy full SHA for 9d55a5e

File tree

Expand file treeCollapse file tree

3 files changed

+21
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+21
-2
lines changed
Open diff view settings
Collapse file

‎lib/internal/url.js‎

Copy file name to clipboardExpand all lines: lib/internal/url.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,19 @@ function update(url, params) {
864864
ctx.search = '?' + serializedParams;
865865
} else {
866866
ctx.search = '';
867+
868+
// Potentially strip trailing spaces from an opaque path
869+
if (ctx.hasOpaquePath && ctx.hash.length === 0) {
870+
let length = ctx.pathname.length;
871+
while (length > 0 && ctx.pathname.charCodeAt(length - 1) === 32) {
872+
length--;
873+
}
874+
875+
// No need to copy the whole string if there is no space at the end
876+
if (length !== ctx.pathname.length) {
877+
ctx.pathname = ctx.pathname.slice(0, length);
878+
}
879+
}
867880
}
868881
ctx.href = constructHref(ctx);
869882
}
Collapse file

‎test/wpt/status/url.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/url.json
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
"skip": "TODO: port from .window.js"
88
},
99
"historical.any.js": {
10-
"requires": ["small-icu"]
10+
"requires": ["small-icu"],
11+
"fail": {
12+
"expected": [
13+
"URL: no structured serialize/deserialize support",
14+
"URLSearchParams: no structured serialize/deserialize support"
15+
]
16+
}
1117
},
1218
"urlencoded-parser.any.js": {
1319
"requires": ["small-icu"]
Collapse file

‎test/wpt/test-url.js‎

Copy file name to clipboardExpand all lines: test/wpt/test-url.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ runner.setScriptModifier((obj) => {
1515
});
1616
runner.pretendGlobalThisAs('Window');
1717
runner.setInitScript(`
18-
globalThis.location = {};
18+
globalThis.location ||= {};
1919
`);
2020
runner.runJsTests();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.