GeezerVison is showing github.com — Trailing slash consistency between __dirname and os.tmpdir() · Issue #715 · nodejs/node
Trailing slash consistency between __dirname and os.tmpdir() #715Labels osIssues and PRs related to the os subsystem. Descriptionconsole.log(os.tmpdir()) // trailing slash
console.log(__dirname) // no trailing slash
Is there a good reason why os.tmpdir() ends with a trailing slash, while __dirname does not? If there is none, it might make sense to make the return values consistent. Activitymicnic commented on Feb 4, 2015 it may be that this is a platform specific issue, for me they are both without trailing slash, what operating system are you using? cjihrig commented on Feb 4, 2015 os.tmpdir() comes directly from environment variables. __dirname uses path.dirname(), which strips trailing slashes.
hacksparrow commented on Feb 4, 2015 tellnes commented on Feb 4, 2015 Maybe we should make os.tmpdir() strip trailing slashes? cjihrig commented on Feb 4, 2015 It would be nice to be consistent, but it could potentially break existing code. tellnes commented on Feb 4, 2015 Yes it will probably break some existing code, but I still see this as a bug. cjihrig commented on Feb 4, 2015 I would be OK with this for a major version bump, but I'd like to hear what others think. hacksparrow commented on Feb 6, 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. micnic commented on Feb 6, 2015 I was looking on Github for modules which use os.tmpdir() and most of them use path methods to deal with it, only about 4 modules out of ~50 that I found were using raw string concatenation which can lead to some issues tellnes commented on Feb 6, 2015 This 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. tellnes commented on Mar 22, 2015
MetadataMetadataosIssues and PRs related to the os subsystem. DevelopmentNo branches or pull requestsIssue actions
|