Skip to content

Commit

Permalink
url: throw error if argument length of revokeObjectURL is 0
Browse files Browse the repository at this point in the history
Added a check to see if url wasn't included as an argument
which will then throw an error.

Fixes: #50432
PR-URL: #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>
  • Loading branch information
DylanTet authored and targos committed Dec 4, 2023
1 parent 8e1a70a commit 6a087ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/internal/url.js
Expand Up @@ -1108,6 +1108,10 @@ function installObjectURLMethods() {
}

function revokeObjectURL(url) {
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('url');
}

bindingBlob.revokeObjectURL(`${url}`);
}

Expand Down
14 changes: 14 additions & 0 deletions 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',
});

0 comments on commit 6a087ce

Please sign in to comment.