Browse Source

path: resolve normalize drive letter to lower case

make path.resolve work the same as path.normalize
v0.11.15-release
dead-horse 10 years ago
committed by Alexis Campailla
parent
commit
f6e5740180
  1. 5
      lib/path.js
  2. 3
      test/simple/test-module-nodemodulepaths.js
  3. 2
      test/simple/test-path.js

5
lib/path.js

@ -163,6 +163,11 @@ if (isWindows) {
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f), resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
!resolvedAbsolute).join('\\'); !resolvedAbsolute).join('\\');
// If device is a drive letter, we'll normalize to lower case.
if (resolvedDevice && resolvedDevice.charAt(1) === ':')
resolvedDevice = resolvedDevice[0].toLowerCase() +
resolvedDevice.substr(1);
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) || return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
'.'; '.';
}; };

3
test/simple/test-module-nodemodulepaths.js

@ -21,6 +21,7 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
var path = require('path');
var module = require('module'); var module = require('module');
@ -29,7 +30,7 @@ var isWindows = process.platform === 'win32';
var file, delimiter, paths; var file, delimiter, paths;
if (isWindows) { if (isWindows) {
file = 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo'; file = path.normalize('C:\\Users\\Rocko Artischocko\\node_stuff\\foo');
delimiter = '\\' delimiter = '\\'
} else { } else {
file = '/usr/test/lib/node_modules/npm/foo'; file = '/usr/test/lib/node_modules/npm/foo';

2
test/simple/test-path.js

@ -321,7 +321,7 @@ if (isWindows) {
[['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'], [['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'],
[['c:/ignore', 'c:/some/file'], 'c:\\some\\file'], [['c:/ignore', 'c:/some/file'], 'c:\\some\\file'],
[['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'], [['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'],
[['.'], process.cwd()], [['.'], path.normalize(process.cwd())],
[['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'], [['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'],
[['c:/', '//'], 'c:\\'], [['c:/', '//'], 'c:\\'],
[['c:/', '//dir'], 'c:\\dir'], [['c:/', '//dir'], 'c:\\dir'],

Loading…
Cancel
Save