Skip to content

Commit f09e321

Browse files
committed
path: don't lower-cases drive letters
In general path functions don't change the case of a path. Making an exception for windows drive letters violates the principle of least surprise. Changing the drive letter case has caused a lot of issues, including nodejs#7031, nodejs#7806 and lots of bikeshedding about whether uppercase is the right case or lowercase. This effectively reverts nodejs/node-v0.x-archive@a05f973 PR-URL: nodejs/node#100
1 parent 890baa0 commit f09e321

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

lib/path.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,6 @@ win32.resolve = function() {
153153
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/),
154154
!resolvedAbsolute).join('\\');
155155

156-
// If device is a drive letter, we'll normalize to lower case.
157-
if (resolvedDevice && resolvedDevice.charAt(1) === ':') {
158-
resolvedDevice = resolvedDevice[0].toLowerCase() +
159-
resolvedDevice.substr(1);
160-
}
161-
162156
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
163157
'.';
164158
};
@@ -172,11 +166,6 @@ win32.normalize = function(path) {
172166
tail = result[3],
173167
trailingSlash = /[\\\/]$/.test(tail);
174168

175-
// If device is a drive letter, we'll normalize to lower case.
176-
if (device && device.charAt(1) === ':') {
177-
device = device[0].toLowerCase() + device.substr(1);
178-
}
179-
180169
// Normalize the tail path
181170
tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\');
182171

test/simple/test-module-nodemodulepaths.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
var common = require('../common');
2323
var assert = require('assert');
24-
var path = require('path');
2524

2625
var module = require('module');
2726

@@ -30,7 +29,7 @@ var isWindows = process.platform === 'win32';
3029
var file, delimiter, paths;
3130

3231
if (isWindows) {
33-
file = path.normalize('C:\\Users\\Rocko Artischocko\\node_stuff\\foo');
32+
file = 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo';
3433
delimiter = '\\'
3534
} else {
3635
file = '/usr/test/lib/node_modules/npm/foo';
@@ -40,4 +39,4 @@ if (isWindows) {
4039
paths = module._nodeModulePaths(file);
4140

4241
assert.ok(paths.indexOf(file + delimiter + 'node_modules') !== -1);
43-
assert.ok(Array.isArray(paths));
42+
assert.ok(Array.isArray(paths));

test/simple/test-path.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ if (isWindows) {
311311
[['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'],
312312
[['c:/ignore', 'c:/some/file'], 'c:\\some\\file'],
313313
[['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'],
314-
[['.'], path.normalize(process.cwd())],
314+
[['.'], process.cwd()],
315315
[['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'],
316316
[['c:/', '//'], 'c:\\'],
317317
[['c:/', '//dir'], 'c:\\dir'],

0 commit comments

Comments
 (0)