diff options
author | 2023-09-12 08:53:43 +0800 | |
---|---|---|
committer | 2023-09-11 17:53:43 -0700 | |
commit | f267c1d097923a2d2992f9f60a6dd365fe706512 (patch) | |
tree | 7f7ad390882e11595fe10744bc8377ff5e760c08 /test/js/node/path/path.test.js | |
parent | c4507a5db33910258278bd6641dcbe34ab33628e (diff) | |
download | bun-f267c1d097923a2d2992f9f60a6dd365fe706512.tar.gz bun-f267c1d097923a2d2992f9f60a6dd365fe706512.tar.zst bun-f267c1d097923a2d2992f9f60a6dd365fe706512.zip |
fix(path): Fix edge case in `path.relative` (#4811)
Close: #4789
Diffstat (limited to 'test/js/node/path/path.test.js')
-rw-r--r-- | test/js/node/path/path.test.js | 13 |
1 files changed, 13 insertions, 0 deletions
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)], + ["../../", "../../", ""], ], ], ]; |