You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
path.posix.relative returns different results for *nix and Windows versions of node #13683
After reading the code found path.posix.relative call posix.resolve first convert path into an absolute path, but posix.resolve's all the parameters have not yet generated an absolute path then it will add the current path to generate the absolute path. Because of current path is platform-related, I think the direct use of path.posix.relative on Windows is not very suitable. And in the debugging of this problem I found the doc of path.relative is not strict, so I also have a PR doc: make path.relative stricter. So I have confusion about this issue, @gibfahn@XadillaX have some advices?
The first solution that comes to mind is adding a check (re #13714): if explicitly running the posix variant of path.posix.relative on a Windows platform, throw a TypeError.
More correct (check resolve): if explicitly running the posix variant of path.posix.resolve on a Windows platform, throw a TypeError
Activity
vsemozhetbyt commentedon Jun 14, 2017
On Windows, Node.js versions differ:
DuanPengfei commentedon Jun 15, 2017
I will try to fix it.
DuanPengfei commentedon Jun 16, 2017
After reading the code found
path.posix.relativecallposix.resolvefirst convert path into an absolute path, butposix.resolve's all the parameters have not yet generated an absolute path then it will add the current path to generate the absolute path. Because of current path is platform-related, I think the direct use ofpath.posix.relativeon Windows is not very suitable. And in the debugging of this problem I found the doc ofpath.relativeis not strict, so I also have a PR doc: makepath.relativestricter. So I have confusion about this issue, @gibfahn @XadillaX have some advices?refack commentedon Jun 16, 2017
The first solution that comes to mind is adding a check (re #13714):
if explicitly running theposixvariant ofpath.posix.relativeon a Windows platform, throw aTypeError.More correct (check
resolve): if explicitly running theposixvariant ofpath.posix.resolveon a Windows platform, throw aTypeErrorXadillaX commentedon Jun 16, 2017
@DuanPengfei you may create a new PR to check and throw error in posix.resolve.
DuanPengfei commentedon Jun 16, 2017
👌🏻I will create a new PR.
24 remaining items
Trott commentedon Mar 15, 2021
I know this issue is quite old, but if anyone wants to test out #37747 to see if it fixes the issue for them, that would be great.
test: add known_issues test for nodejs#13683
test: add known_issues test for #13683
path: fix posix.relative() on Windows
path: fix posix.relative() on Windows
test: add known_issues test for #13683