Skip to content

Commit

Permalink
path: resolve normalize drive letter to lower case
Browse files Browse the repository at this point in the history
make path.resolve work the same as path.normalize
  • Loading branch information
不四 committed Sep 23, 2014
1 parent 21e6064 commit dc1293b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ if (isWindows) {
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
!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) ||
'.';
};
Expand Down
4 changes: 3 additions & 1 deletion test/simple/test-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@ if (isWindows) {
// path.resolve tests
if (isWindows) {
// windows
var cwd = process.cwd();
cwd = cwd[0].toLowerCase() + cwd.substr(1);
var resolveTests =
// arguments result
[[['c:/blah\\blah', 'd:/games', 'c:../a'], 'c:\\blah\\a'],
[['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'],
[['c:/ignore', 'c:/some/file'], 'c:\\some\\file'],
[['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'],
[['.'], process.cwd()],
[['.'], cwd],
[['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'],
[['c:/', '//'], 'c:\\'],
[['c:/', '//dir'], 'c:\\dir'],
Expand Down

0 comments on commit dc1293b

Please sign in to comment.