url: validate URL constructor arg length

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Khafra authored and Node.js GitHub Bot committed 2023-04-13 15:31:09 +00:00
1 parent a07caf3f92
commit 50d510f0de
3 files changed
+23 -12

No files matched your search

+4
View File
@@ -706,6 +706,10 @@ class URL {
#searchParams;
constructor(input, base = undefined) {
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('url');
}
// toUSVString is not needed.
input = `${input}`;
+12 -12
View File
@@ -1,12 +1,12 @@
'use strict';
require('../common');
const assert = require('assert');
// One argument is required
assert.throws(() => {
URL.canParse();
}, {
code: 'ERR_MISSING_ARGS',
name: 'TypeError'
});
'use strict';
require('../common');
const assert = require('assert');
// One argument is required
assert.throws(() => {
URL.canParse();
}, {
code: 'ERR_MISSING_ARGS',
name: 'TypeError',
});
@@ -78,3 +78,10 @@ for (const test of additional_tests) {
if (test.search) assert.strictEqual(url.search, test.search);
if (test.hash) assert.strictEqual(url.hash, test.hash);
}
assert.throws(() => {
new URL();
}, {
name: 'TypeError',
code: 'ERR_MISSING_ARGS',
});