Skip to content

Commit 268fc13

Browse files
committed
fixup! move string construction to c++
1 parent 869ff2a commit 268fc13

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

lib/internal/url.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,9 +1036,7 @@ function installObjectURLMethods() {
10361036

10371037
const id = cryptoRandom.randomUUID();
10381038

1039-
bindingBlob.storeDataObject(id, obj[blob.kHandle], obj.size, obj.type);
1040-
1041-
return `blob:nodedata:${id}`;
1039+
return bindingBlob.storeDataObject(id, obj[blob.kHandle], obj.size, obj.type);
10421040
}
10431041

10441042
function revokeObjectURL(url) {

src/node_blob.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,19 @@ void Blob::StoreDataObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
391391

392392
size_t length = args[2].As<Uint32>()->Value();
393393
Utf8Value type(env->isolate(), args[3]);
394+
std::string key_str(*key, key.length());
394395

395396
binding_data->store_data_object(
396-
std::string(*key, key.length()),
397-
BlobBindingData::StoredDataObject(
398-
BaseObjectPtr<Blob>(blob),
399-
length,
400-
std::string(*type, type.length())));
397+
key_str,
398+
BlobBindingData::StoredDataObject(BaseObjectPtr<Blob>(blob),
399+
length,
400+
std::string(*type, type.length())));
401+
std::string final_url = "blob:nodedata:" + key_str;
402+
args.GetReturnValue().Set(String::NewFromUtf8(env->isolate(),
403+
final_url.c_str(),
404+
v8::NewStringType::kNormal,
405+
final_url.length())
406+
.ToLocalChecked());
401407
}
402408

403409
void RevokeObjectURLImpl(std::string_view input,
@@ -431,7 +437,6 @@ void Blob::RevokeObjectURL(const FunctionCallbackInfo<Value>& args) {
431437

432438
void Blob::FastRevokeObjectURL(Local<Value> receiver,
433439
const FastOneByteString& input) {
434-
printf("FastRevokeObjectURL\n");
435440
BlobBindingData* binding_data = FromJSObject<BlobBindingData>(receiver);
436441
std::string_view input_view(input.data, input.length);
437442
RevokeObjectURLImpl(input_view, binding_data);

0 commit comments

Comments
 (0)