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 e46bdcf

Browse filesBrowse files
jasnellItalo A. Casas
authored andcommitted
url: change null password handling
Pulls in new URL parsing tests from w3c web-platform-tests and updates null password handling. Refs: web-platform-tests/wpt@e001240 Refs: whatwg/url#186 PR-URL: #10601 Fixes: #10595 Reviewed-By: Michal Zasso <targos@protonmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent f380a5f commit e46bdcf
Copy full SHA for e46bdcf

File tree

Expand file treeCollapse file tree

2 files changed

+66
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+66
-5
lines changed
Open diff view settings
Collapse file

‎lib/internal/url.js‎

Copy file name to clipboardExpand all lines: lib/internal/url.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ Object.defineProperties(URL.prototype, {
285285
if (ctx.host !== undefined) {
286286
ret += '//';
287287
const has_username = typeof ctx.username === 'string';
288-
const has_password = typeof ctx.password === 'string';
288+
const has_password = typeof ctx.password === 'string' &&
289+
ctx.password !== '';
289290
if (has_username || has_password) {
290291
if (has_username)
291292
ret += ctx.username;
Collapse file

‎test/fixtures/url-tests.json‎

Copy file name to clipboardExpand all lines: test/fixtures/url-tests.json
+64-4Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,66 @@
3232
"search": "?b",
3333
"hash": "#c"
3434
},
35+
{
36+
"input": "https://test:@test",
37+
"base": "about:blank",
38+
"href": "https://test@test/",
39+
"origin": "https://test",
40+
"protocol": "https:",
41+
"username": "test",
42+
"password": "",
43+
"host": "test",
44+
"hostname": "test",
45+
"port": "",
46+
"pathname": "/",
47+
"search": "",
48+
"hash": ""
49+
},
50+
{
51+
"input": "https://:@test",
52+
"base": "about:blank",
53+
"href": "https://test/",
54+
"origin": "https://test",
55+
"protocol": "https:",
56+
"username": "",
57+
"password": "",
58+
"host": "test",
59+
"hostname": "test",
60+
"port": "",
61+
"pathname": "/",
62+
"search": "",
63+
"hash": ""
64+
},
65+
{
66+
"input": "non-special://test:@test/x",
67+
"base": "about:blank",
68+
"href": "non-special://test@test/x",
69+
"origin": "null",
70+
"protocol": "non-special:",
71+
"username": "test",
72+
"password": "",
73+
"host": "test",
74+
"hostname": "test",
75+
"port": "",
76+
"pathname": "/x",
77+
"search": "",
78+
"hash": ""
79+
},
80+
{
81+
"input": "non-special://:@test/x",
82+
"base": "about:blank",
83+
"href": "non-special://test/x",
84+
"origin": "null",
85+
"protocol": "non-special:",
86+
"username": "",
87+
"password": "",
88+
"host": "test",
89+
"hostname": "test",
90+
"port": "",
91+
"pathname": "/x",
92+
"search": "",
93+
"hash": ""
94+
},
3595
{
3696
"input": "http:foo.com",
3797
"base": "http://example.org/foo/bar",
@@ -3098,7 +3158,7 @@
30983158
{
30993159
"input": "http:a:@www.example.com",
31003160
"base": "about:blank",
3101-
"href": "http://a:@www.example.com/",
3161+
"href": "http://a@www.example.com/",
31023162
"origin": "http://www.example.com",
31033163
"protocol": "http:",
31043164
"username": "a",
@@ -3113,7 +3173,7 @@
31133173
{
31143174
"input": "http:/a:@www.example.com",
31153175
"base": "about:blank",
3116-
"href": "http://a:@www.example.com/",
3176+
"href": "http://a@www.example.com/",
31173177
"origin": "http://www.example.com",
31183178
"protocol": "http:",
31193179
"username": "a",
@@ -3128,7 +3188,7 @@
31283188
{
31293189
"input": "http://a:@www.example.com",
31303190
"base": "about:blank",
3131-
"href": "http://a:@www.example.com/",
3191+
"href": "http://a@www.example.com/",
31323192
"origin": "http://www.example.com",
31333193
"protocol": "http:",
31343194
"username": "a",
@@ -3173,7 +3233,7 @@
31733233
{
31743234
"input": "http://:@www.example.com",
31753235
"base": "about:blank",
3176-
"href": "http://:@www.example.com/",
3236+
"href": "http://www.example.com/",
31773237
"origin": "http://www.example.com",
31783238
"protocol": "http:",
31793239
"username": "",

0 commit comments

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