aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resolver/resolve_path.zig4
-rw-r--r--test/js/node/path/path.test.js13
2 files changed, 15 insertions, 2 deletions
diff --git a/src/resolver/resolve_path.zig b/src/resolver/resolve_path.zig
index 4800d7d90..f74211709 100644
--- a/src/resolver/resolve_path.zig
+++ b/src/resolver/resolve_path.zig
@@ -471,7 +471,7 @@ pub fn relativePlatform(from: []const u8, to: []const u8, comptime platform: Pla
Fs.FileSystem.instance.top_level_dir,
&relative_from_buf,
&[_][]const u8{
- normalizeStringBuf(from, relative_from_buf[1..], false, platform, true),
+ normalizeStringBuf(from, relative_from_buf[1..], true, platform, true),
},
platform,
);
@@ -484,7 +484,7 @@ pub fn relativePlatform(from: []const u8, to: []const u8, comptime platform: Pla
Fs.FileSystem.instance.top_level_dir,
&relative_to_buf,
&[_][]const u8{
- normalizeStringBuf(to, relative_to_buf[1..], false, platform, true),
+ normalizeStringBuf(to, relative_to_buf[1..], true, platform, true),
},
platform,
);
diff --git a/test/js/node/path/path.test.js b/test/js/node/path/path.test.js
index 3c8a04d72..5865d6182 100644
--- a/test/js/node/path/path.test.js
+++ b/test/js/node/path/path.test.js
@@ -415,6 +415,9 @@ it("path.join", () => {
it("path.relative", () => {
const failures = [];
+ const cwd = process.cwd();
+ const cwdParent = path.dirname(cwd);
+ const parentIsRoot = cwdParent == "/";
const relativeTests = [
// [
@@ -477,6 +480,16 @@ it("path.relative", () => {
["/webp4ck-hot-middleware", "/webpack/buildin/module.js", "../webpack/buildin/module.js"],
["/webpack-hot-middleware", "/webp4ck/buildin/module.js", "../webp4ck/buildin/module.js"],
["/var/webpack-hot-middleware", "/var/webpack/buildin/module.js", "../webpack/buildin/module.js"],
+ ["/app/node_modules/pkg", "../static", `../../..${parentIsRoot ? "" : cwdParent}/static`],
+ ["/app/node_modules/pkg", "../../static", `../../..${parentIsRoot ? "" : path.dirname(cwdParent)}/static`],
+ ["/app", "../static", `..${parentIsRoot ? "" : cwdParent}/static`],
+ ["/app", "../".repeat(64) + "static", "../static"],
+ [".", "../static", cwd == "/" ? "static" : "../static"],
+ ["/", "../static", parentIsRoot ? "static" : `${cwdParent}/static`.slice(1)],
+ ["../", "../", ""],
+ ["../", "../../", parentIsRoot ? "" : ".."],
+ ["../../", "../", parentIsRoot ? "" : path.basename(cwdParent)],
+ ["../../", "../../", ""],
],
],
];