Skip to content

Commit 016e084

Browse files
piscisaureusJulien Gilli
authored and
Julien Gilli
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/node-v0.x-archive#7031, nodejs/node-v0.x-archive#7806 and lots of bikeshedding about whether uppercase is the right case or lowercase. This effectively reverts nodejs/node-v0.x-archive@a05f973 Reviewed-by: Alexis Campailla <[email protected]> Reviewed-by: Julien Gilli <[email protected]>
1 parent 67f87a7 commit 016e084

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

lib/path.js

-11
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

+1-2
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';

test/simple/test-path.js

+1-1
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)