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 180d365

Browse filesBrowse files
KhafraDevtargos
authored andcommitted
url: validate URL constructor arg length
PR-URL: #47513 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 4839fc4 commit 180d365
Copy full SHA for 180d365

File tree

Expand file treeCollapse file tree

3 files changed

+23
-12
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+23
-12
lines changed
Open diff view settings
Collapse file

‎lib/internal/url.js‎

Copy file name to clipboardExpand all lines: lib/internal/url.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,10 @@ class URL {
706706
#searchParams;
707707

708708
constructor(input, base = undefined) {
709+
if (arguments.length === 0) {
710+
throw new ERR_MISSING_ARGS('url');
711+
}
712+
709713
// toUSVString is not needed.
710714
input = `${input}`;
711715

Collapse file
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
'use strict';
2-
3-
require('../common');
4-
const assert = require('assert');
5-
6-
// One argument is required
7-
assert.throws(() => {
8-
URL.canParse();
9-
}, {
10-
code: 'ERR_MISSING_ARGS',
11-
name: 'TypeError'
12-
});
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
// One argument is required
7+
assert.throws(() => {
8+
URL.canParse();
9+
}, {
10+
code: 'ERR_MISSING_ARGS',
11+
name: 'TypeError',
12+
});
Collapse file

‎test/parallel/test-whatwg-url-custom-parsing.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-url-custom-parsing.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,10 @@ for (const test of additional_tests) {
7878
if (test.search) assert.strictEqual(url.search, test.search);
7979
if (test.hash) assert.strictEqual(url.hash, test.hash);
8080
}
81+
82+
assert.throws(() => {
83+
new URL();
84+
}, {
85+
name: 'TypeError',
86+
code: 'ERR_MISSING_ARGS',
87+
});

0 commit comments

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