Repository navigation
Trailing slash consistency between __dirname and os.tmpdir() #715
Description
Activity
it may be that this is a platform specific issue, for me they are both without trailing slash, what operating system are you using?
os.tmpdir()comes directly from environment variables.__dirnameusespath.dirname(), which strips trailing slashes.Mac OS.
Maybe we should make
os.tmpdir()strip trailing slashes?It would be nice to be consistent, but it could potentially break existing code.
Yes it will probably break some existing code, but I still see this as a bug.
I would be OK with this for a major version bump, but I'd like to hear what others think.
- addedosIssues and PRs related to the os subsystem.Issues and PRs related to the os subsystem.
on Feb 5, 2015 Right now I am getting through by adding a mandatory '/' everywhere I suspect the slash may or may not be found, and using
path.normalize(). But it is an inelegant solution.Probably iojs should work on normalizing the trailing slash to provide for a consistent interface. It is a pain when something works on Mac and fails on Linux, and vice versa.
I was looking on Github for modules which use
os.tmpdir()and most of them usepathmethods to deal with it, only about 4 modules out of ~50 that I found were using raw string concatenation which can lead to some issuesThis is a quick fix in io.js and a quick fix in those modules if they break. I'll go ahead and create a pull request and then the only thing left is to choose whether to merge or not.
- added a commit that references this issue
on Mar 21, 2015 Landed in next branch as bb97b70
- added a commit that references this issue
on Apr 28, 2015
Is there a good reason why
os.tmpdir()ends with a trailing slash, while__dirnamedoes not? If there is none, it might make sense to make the return values consistent.