aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ai Hoshino <ambiguous404@gmail.com> 2023-08-07 21:44:04 +0800
committerGravatar GitHub <noreply@github.com> 2023-08-07 06:44:04 -0700
commit5ce393aab815f38ce9594d8a7d481a608ee8524c (patch)
tree5a9e64ef0f24e478c0ad02ec3d3d6c8447eef7ec
parent00a907c7de842787e87b0d0a42d8d33704c5aaae (diff)
downloadbun-5ce393aab815f38ce9594d8a7d481a608ee8524c.tar.gz
bun-5ce393aab815f38ce9594d8a7d481a608ee8524c.tar.zst
bun-5ce393aab815f38ce9594d8a7d481a608ee8524c.zip
Fix `path.normalize` edge case. (#4042)
Close: #4041
-rw-r--r--src/bun.js/node/types.zig2
-rw-r--r--test/js/node/path/path.test.js1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig
index 3ba3db5b9..c858c9b04 100644
--- a/src/bun.js/node/types.zig
+++ b/src/bun.js/node/types.zig
@@ -2008,7 +2008,7 @@ pub const Path = struct {
if (args_len == 0) return JSC.ZigString.init("").toValue(globalThis);
var zig_str: JSC.ZigString = args_ptr[0].getZigString(globalThis);
- if (zig_str.len == 0) return JSC.ZigString.init("").toValue(globalThis);
+ if (zig_str.len == 0) return JSC.ZigString.init(".").toValue(globalThis);
var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
var str_slice = zig_str.toSlice(heap_allocator);
diff --git a/test/js/node/path/path.test.js b/test/js/node/path/path.test.js
index fb6063968..0df4f5abb 100644
--- a/test/js/node/path/path.test.js
+++ b/test/js/node/path/path.test.js
@@ -566,6 +566,7 @@ it("path.normalize", () => {
strictEqual(path.posix.normalize("../foobar/barfoo/foo/../../../bar/../../"), "../../");
strictEqual(path.posix.normalize("../.../../foobar/../../../bar/../../baz"), "../../../../baz");
strictEqual(path.posix.normalize("foo/bar\\baz"), "foo/bar\\baz");
+ strictEqual(path.posix.normalize(""), ".");
});
it("path.resolve", () => {