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
Behavior of path.basename is different from basename command. #7519
path.basename() is closer to man 3 basename than it is to man 1 basename. Using python's ctypes because I don't feel like writing a C program to demonstrate the point:
The only mildly surprising behavior of node's basename() is this:
path.basename('//', '/')
// => '//'
The second '/' is interpreted as the extension. You could argue the result is wrong but the entire expression is rather nonsensical. A clear case of GIGO, IMO.
I sended this issue as a point I noticed, and It's not that I want you to modify it strongly. If you don't think that this is not a problem, this issue can be closed.
Activity
sttk commentedon Jul 3, 2016
PS:
Fishrock123 commentedon Jul 4, 2016
I don't think there is anywhere stating that it would be the same as
basename(1)?That is pretty curious though.
bnoordhuis commentedon Jul 4, 2016
path.basename()is closer toman 3 basenamethan it is toman 1 basename. Using python's ctypes because I don't feel like writing a C program to demonstrate the point:The only mildly surprising behavior of node's basename() is this:
The second '/' is interpreted as the extension. You could argue the result is wrong but the entire expression is rather nonsensical. A clear case of GIGO, IMO.
sttk commentedon Jul 4, 2016
I sended this issue as a point I noticed, and It's not that I want you to modify it strongly. If you don't think that this is not a problem, this issue can be closed.
sttk commentedon Jul 7, 2016
I found one more different behavior of
path.basenamefrombasenamecommand.But if you think this is not a problem, you can ignore this post.