mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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:
1 parent
a07caf3f92
commit
50d510f0de
3 files changed
+23
-12
No files matched your search
@@ -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}`;
|
||||
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
Reference in new issue
Block a user