-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
joinPath
sometimes has extra .
in the beginning of the path
#23712
Comments
While looking at the code, I have found out that there are two issues basically. In Lines 590 to 863 in 0b5a938
Retaining this behavior might be good to prevent older programs from breaking, but it starts to look much weirder in case of joinPath("b", "..", "a") or joinPath(".", "..") , so probably worth either fixing or documenting.
The second part is less controversial and more looks like a bug. The problem is in the line Line 75 in 0b5a938
This is not the correct way to check if it's the first component of the path, as state == 0 holds also for such paths as . or ../.. . Thus, when handling joinPath("x/..", "/a", "/b", "../../..") it starts to think at some point that the path is absolute, because it receives "/" from PathIter . Though, by coincidence and only because the . is not removed because of the first issue, it seems that such incorrect state doesn't lead to wrong results (or at least I haven't been able to found the failing case).
|
But |
Well, but import std/[os, paths]
echo normalizedPath("./a")
echo "./a".Path == "a".Path prints
And the documentation promises that Nim/lib/std/private/ospaths2.nim Lines 96 to 98 in 0b5a938
but ./a is obviously not normalized.
|
Description
Nim Version
2.0.4 (also reproducible on the latest devel)
Current Output
Expected Output
Possible Solution
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: