mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
url: validate argument length in canParse
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:
parent
dac8de689b
commit
a07caf3f92
@ -978,6 +978,10 @@ class URL {
|
||||
}
|
||||
|
||||
static canParse(url, base = undefined) {
|
||||
if (arguments.length === 0) {
|
||||
throw new ERR_MISSING_ARGS('url');
|
||||
}
|
||||
|
||||
url = `${url}`;
|
||||
|
||||
if (base !== undefined) {
|
||||
|
12
test/parallel/test-url-canParse-whatwg.js
Normal file
12
test/parallel/test-url-canParse-whatwg.js
Normal file
@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
|
||||
// One argument is required
|
||||
assert.throws(() => {
|
||||
URL.canParse();
|
||||
}, {
|
||||
code: 'ERR_MISSING_ARGS',
|
||||
name: 'TypeError'
|
||||
});
|
Loading…
Reference in New Issue
Block a user