-
Notifications
You must be signed in to change notification settings - Fork 30k
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
path (extname, parse) cannot handle extension correctly for directory #6229
Comments
the challenge here is that the |
This is why in general it's typically a good idea to append a trailing path separator to indicate a directory. However that won't help with parsing this path (which could possibly be viewed as a bug). |
if you put a slash at the end, you will have the same results. |
Right, I noted that. It could perhaps be viewed as a bug in that case shrug. |
Actually, that does sound like a bug. |
Refs: nodejs#6229 PR-URL: nodejs#8293 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
I think we are talking about two unrelated problems. @francisl suggests that the result of
No modern file system relies on file extensions (let's not talk about 8.3) and all major operating systems support (almost) arbitrary combinations of I cannot think of any problems related to this behavior, maybe close this issue? @jasnell I think it is a little awkward to break with traditional path resolution, but I see you already pulled that. See
|
I agree. The The fact that trailing slashes are ignored might be surprising to some but it's consistent with how basename(1) and basename(3) work. It should probably be documented but that's all, pull requests welcome. I'll go ahead and close this out. |
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. Refs: nodejs#6229
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: #12181 Fixes: #6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Add notes about path.parse(), path.basename() and path.dirname() ignoring trailing slashes. PR-URL: nodejs/node#12181 Fixes: nodejs/node#6229 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This test precedented the official documentation that states that this is an expected behavior. Refs: nodejs#6229 Refs: nodejs#12181
This test precedented the official documentation that states that this is an expected behavior. PR-URL: nodejs#26913 Refs: nodejs#6229 Refs: nodejs#12181 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
For future readers, if the path can only be folder, we can use |
On OS X and Linux its perfectly legal to use dot '.' in directory name.
Currently path.extname and path.parse handle
.
in directory name as a file extension.e.g.
I understand that
path
don't do any validation. But this behavior is confusing an error prone.The text was updated successfully, but these errors were encountered: