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 <[email protected]>
Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Zeyu "Alex" Yang <[email protected]>
  • Loading branch information
DylanTet authored and richardlau committed Mar 25, 2024
1 parent 450163c commit 2acbcbd
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
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,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
Original file line number Diff line number Diff line change
@@ -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 2acbcbd

Please sign in to comment.