Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

path: Do not coerce paths to strings on Windows

Fix #4795
  • Loading branch information...
commit 0cced7dbf2638944b3a6d700c0090a9bb4aa895e 1 parent d69a26b
Isaac Z. Schlueter authored

Showing 2 changed files with 13 additions and 5 deletions. Show diff stats Hide diff stats

  1. +3 1 lib/path.js
  2. +10 4 test/simple/test-path-makelong.js
4 lib/path.js
@@ -448,7 +448,9 @@ exports.existsSync = util.deprecate(function(path) {
448 448
449 449 if (isWindows) {
450 450 exports._makeLong = function(path) {
451   - path = '' + path;
  451 + if (typeof path !== 'string')
  452 + return path;
  453 +
452 454 if (!path) {
453 455 return '';
454 456 }
14 test/simple/test-path-makelong.js
@@ -19,11 +19,11 @@
19 19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
21 21
22   -if (process.platform === 'win32') {
23   - var assert = require('assert');
24   - var path = require('path');
25   - var common = require('../common');
  22 +var assert = require('assert');
  23 +var path = require('path');
  24 +var common = require('../common');
26 25
  26 +if (process.platform === 'win32') {
27 27 var file = path.join(common.fixturesDir, 'a.js');
28 28 var resolvedFile = path.resolve(file);
29 29
@@ -36,3 +36,9 @@ if (process.platform === 'win32') {
36 36 assert.equal('\\\\.\\pipe\\somepipe',
37 37 path._makeLong('\\\\.\\pipe\\somepipe'));
38 38 }
  39 +
  40 +assert.equal(path._makeLong(null), null);
  41 +assert.equal(path._makeLong(100), 100);
  42 +assert.equal(path._makeLong(path), path);
  43 +assert.equal(path._makeLong(false), false);
  44 +assert.equal(path._makeLong(true), true);

0 comments on commit 0cced7d

Please sign in to comment.
Something went wrong with that request. Please try again.