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 4839fc4

Browse filesBrowse files
KhafraDevtargos
authored andcommitted
url: validate argument length in canParse
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 ede69d2 commit 4839fc4
Copy full SHA for 4839fc4

File tree

Expand file treeCollapse file tree

2 files changed

+16
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-0
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
@@ -978,6 +978,10 @@ class URL {
978978
}
979979

980980
static canParse(url, base = undefined) {
981+
if (arguments.length === 0) {
982+
throw new ERR_MISSING_ARGS('url');
983+
}
984+
981985
url = `${url}`;
982986

983987
if (base !== undefined) {
Collapse file
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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+
});

0 commit comments

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