From 5f66408edcb01b6a2e13819d03a13e8c48d6b23e Mon Sep 17 00:00:00 2001 From: Dylan Date: Fri, 27 Oct 2023 11:37:45 -0700 Subject: [PATCH] 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 --- lib/internal/url.js | 4 ++++ test/parallel/test-url-revokeobjecturl.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/parallel/test-url-revokeobjecturl.js diff --git a/lib/internal/url.js b/lib/internal/url.js index ca41c48582b19d..e4862050784f38 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1104,6 +1104,10 @@ function installObjectURLMethods() { } function revokeObjectURL(url) { + if (arguments.length === 0) { + throw new ERR_MISSING_ARGS('url'); + } + bindingBlob.revokeObjectURL(`${url}`); } diff --git a/test/parallel/test-url-revokeobjecturl.js b/test/parallel/test-url-revokeobjecturl.js new file mode 100644 index 00000000000000..dae980c4d0074c --- /dev/null +++ b/test/parallel/test-url-revokeobjecturl.js @@ -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', +});