url: throw error if argument length of revokeObjectURL is 0

Added a check to see if url wasn't included as an argument
which will then throw an error.

Fixes: https://github.com/nodejs/node/issues/50432
PR-URL: https://github.com/nodejs/node/pull/50433
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
This commit is contained in:
DylanTet 2023-11-30 13:26:56 -08:00 committed by GitHub
parent b7d2827ce0
commit 2f4065250e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -1108,6 +1108,10 @@ function installObjectURLMethods() {
}
function revokeObjectURL(url) {
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('url');
}
bindingBlob.revokeObjectURL(`${url}`);
}

View File

@ -0,0 +1,14 @@
'use strict';
require('../common');
// Test ensures that the function receives the url argument.
const assert = require('node:assert');
assert.throws(() => {
URL.revokeObjectURL();
}, {
code: 'ERR_MISSING_ARGS',
name: 'TypeError',
});