Skip to content

Commit bf4ee17

Browse files
KhafraDevtargos
authored andcommitted
url: validate argument length in canParse
PR-URL: #47513 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Filip Skokan <[email protected]>
1 parent 88f9ebb commit bf4ee17

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/internal/url.js

+4
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,10 @@ class URL {
964964
}
965965

966966
static canParse(url, base = undefined) {
967+
if (arguments.length === 0) {
968+
throw new ERR_MISSING_ARGS('url');
969+
}
970+
967971
url = `${url}`;
968972

969973
if (base !== undefined) {
+12
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)