aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/node/types.zig2
-rw-r--r--test/js/node/path/path.test.js5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig
index 6162bf9e4..81073463a 100644
--- a/src/bun.js/node/types.zig
+++ b/src/bun.js/node/types.zig
@@ -1826,7 +1826,7 @@ pub const Path = struct {
const base_slice = path.slice();
- return JSC.ZigString.init(std.fs.path.extension(base_slice)).toValueGC(globalThis);
+ return JSC.ZigString.init(std.fs.path.extension(base_slice)).withEncoding().toValueGC(globalThis);
}
pub fn format(globalThis: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(.C) JSC.JSValue {
if (comptime is_bindgen) return JSC.JSValue.jsUndefined();
diff --git a/test/js/node/path/path.test.js b/test/js/node/path/path.test.js
index 567e837af..030a7443a 100644
--- a/test/js/node/path/path.test.js
+++ b/test/js/node/path/path.test.js
@@ -692,3 +692,8 @@ it("path.parse", () => {
test("path.format works for vite's example", () => {
expect(path.format({ root: "", dir: "", name: "index", base: undefined, ext: ".css" })).toBe("index.css");
});
+
+it("path.extname", () => {
+ expect(path.extname("index.js")).toBe(".js");
+ expect(path.extname("make_plot.🔥")).toBe(".🔥");
+});