Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: skip revoke_data_object if uuid is not found #42212

Merged
merged 1 commit into from
Mar 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/api/url.md
Original file line number Diff line number Diff line change
@@ -659,7 +659,8 @@ added: v16.7.0
* `id` {string} A `'blob:nodedata:...` URL string returned by a prior call to
`URL.createObjectURL()`.

Removes the stored {Blob} identified by the given ID.
Removes the stored {Blob} identified by the given ID. Attempting to revoke a
ID that isn’t registered will silently fail.

### Class: `URLSearchParams`

4 changes: 3 additions & 1 deletion src/node_blob.cc
Original file line number Diff line number Diff line change
@@ -444,7 +444,9 @@ void BlobBindingData::store_data_object(
}

void BlobBindingData::revoke_data_object(const std::string& uuid) {
CHECK_NE(data_objects_.find(uuid), data_objects_.end());
if (data_objects_.find(uuid) == data_objects_.end()) {
return;
}
data_objects_.erase(uuid);
CHECK_EQ(data_objects_.find(uuid), data_objects_.end());
}
4 changes: 4 additions & 0 deletions test/parallel/test-blob-createobjecturl.js
Original file line number Diff line number Diff line change
@@ -29,6 +29,10 @@ const assert = require('assert');
Buffer.from(await otherBlob.arrayBuffer()).toString(),
'hello');
URL.revokeObjectURL(id);

// should do nothing
URL.revokeObjectURL(id);

assert.strictEqual(resolveObjectURL(id), undefined);

// Leaving a Blob registered should not cause an assert