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: nodejs#50432
PR-URL: nodejs#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 Nov 30, 2023
1 parent b7d2827 commit 2f40652
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 @@ -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
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 2f40652

Please sign in to comment.