diff options
author | 2023-08-04 03:34:41 +0800 | |
---|---|---|
committer | 2023-08-03 12:34:41 -0700 | |
commit | 30dde625214daf60c8ee4d1a7d132bdb3a175f17 (patch) | |
tree | a66a9cd87c71ac7c6ab857b00b462174ebdc7735 | |
parent | 928816bef0945e9655c115767c719d6865ff138c (diff) | |
download | bun-30dde625214daf60c8ee4d1a7d132bdb3a175f17.tar.gz bun-30dde625214daf60c8ee4d1a7d132bdb3a175f17.tar.zst bun-30dde625214daf60c8ee4d1a7d132bdb3a175f17.zip |
Fix the string encoding in `path.extname`. (#3949)
Close: #3948
-rw-r--r-- | src/bun.js/node/types.zig | 2 | ||||
-rw-r--r-- | test/js/node/path/path.test.js | 5 |
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(".🔥"); +}); |