diff options
author | Christian Tellnes <christian@tellnes.no> | 2015-02-06 23:27:22 +0100 |
---|---|---|
committer | Chris Dickinson <christopher.s.dickinson@gmail.com> | 2015-04-28 14:38:14 -0700 |
commit | b57cc51d8d3f4ad279591ae8fa6584ee22773b97 (patch) | |
tree | fa4a560d579c949c4e9cae4838ac92a120ee8e47 /lib/os.js | |
parent | 1bcdf46ca750a1e2ede7824ad5359d501675c430 (diff) | |
download | android-node-v8-b57cc51d8d3f4ad279591ae8fa6584ee22773b97.tar.gz android-node-v8-b57cc51d8d3f4ad279591ae8fa6584ee22773b97.tar.bz2 android-node-v8-b57cc51d8d3f4ad279591ae8fa6584ee22773b97.zip |
os: remove trailing slash from os.tmpdir()
This commit makes `os.tmpdir()` behave consistently on all platforms. It
changes `os.tmpdir()` to always return a path without trailing slash.
Semver: major
Fixes: https://github.com/iojs/io.js/issues/715
PR-URL: https://github.com/iojs/io.js/pull/747
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/os.js')
-rw-r--r-- | lib/os.js | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -23,16 +23,20 @@ exports.platform = function() { }; exports.tmpdir = function() { + var path; if (isWindows) { - return process.env.TEMP || + path = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + '\\temp'; } else { - return process.env.TMPDIR || + path = process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp'; } + if (/[\\\/]$/.test(path)) + path = path.slice(0, -1); + return path; }; exports.tmpDir = exports.tmpdir; |