aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/webcore/blob.zig
diff options
context:
space:
mode:
authorGravatar Dylan Conway <35280289+dylan-conway@users.noreply.github.com> 2023-08-31 17:33:08 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-31 17:33:08 -0700
commitfef70f2473daefe242c80b9f3f34ef67396efaef (patch)
tree2f6dce4958d0a954115b6279deef418d9c8c340e /src/bun.js/webcore/blob.zig
parentbd7262f037589a69be8b5fb2f705666309c32b86 (diff)
downloadbun-fef70f2473daefe242c80b9f3f34ef67396efaef.tar.gz
bun-fef70f2473daefe242c80b9f3f34ef67396efaef.tar.zst
bun-fef70f2473daefe242c80b9f3f34ef67396efaef.zip
get name if not provided in `FormData.append` (#4434)
* get file name from blob if not provided * add test * another test * format
Diffstat (limited to 'src/bun.js/webcore/blob.zig')
-rw-r--r--src/bun.js/webcore/blob.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig
index 25f762e97..54c37e679 100644
--- a/src/bun.js/webcore/blob.zig
+++ b/src/bun.js/webcore/blob.zig
@@ -510,11 +510,20 @@ pub const Blob = struct {
this.finalize();
}
+ export fn Blob__getFileNameString(this: *Blob) callconv(.C) bun.String {
+ if (this.getFileName()) |filename| {
+ return bun.String.fromBytes(filename);
+ }
+
+ return bun.String.empty;
+ }
+
comptime {
_ = Blob__dupeFromJS;
_ = Blob__destroy;
_ = Blob__dupe;
_ = Blob__setAsFile;
+ _ = Blob__getFileNameString;
}
pub fn writeFormatForSize(size: usize, writer: anytype, comptime enable_ansi_colors: bool) !void {