diff options
author | 2023-05-09 21:44:05 -0700 | |
---|---|---|
committer | 2023-05-09 21:44:05 -0700 | |
commit | c7c5dc14384f81a2d245870d2848c0512193690d (patch) | |
tree | 92da71a371cff795f0fd1b886fece062879af372 /src/bun.js/webcore/blob.zig | |
parent | a5b3056c76268e4bf219f68a15827be5b564313b (diff) | |
download | bun-c7c5dc14384f81a2d245870d2848c0512193690d.tar.gz bun-c7c5dc14384f81a2d245870d2848c0512193690d.tar.zst bun-c7c5dc14384f81a2d245870d2848c0512193690d.zip |
Add `name` property
Diffstat (limited to 'src/bun.js/webcore/blob.zig')
-rw-r--r-- | src/bun.js/webcore/blob.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index f0692d482..4005a6bcc 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -2544,6 +2544,25 @@ pub const Blob = struct { return ZigString.Empty.toValue(globalThis); } + // TODO: Move this to a separate `File` object or BunFile + pub fn getName( + this: *Blob, + globalThis: *JSC.JSGlobalObject, + ) callconv(.C) JSValue { + if (this.store) |store| { + if (store.data == .file) { + if (store.data.file.pathlike == .path) { + return ZigString.fromUTF8(store.data.file.pathlike.path.slice()).toValueGC(globalThis); + } + + // we shouldn't return Number here. + } + } + + return JSC.JSValue.jsUndefined(); + } + + // TODO: Move this to a separate `File` object or BunFile pub fn getLastModified( this: *Blob, _: *JSC.JSGlobalObject, |