From 016e08458cc38d7324c907c6594f2b56a5a19719 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Tue, 23 Dec 2014 21:35:35 +0100 Subject: [PATCH] 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 joyent/node#7031, joyent/node#7806 and lots of bikeshedding about whether uppercase is the right case or lowercase. This effectively reverts joyent/node@a05f973 Reviewed-by: Alexis Campailla Reviewed-by: Julien Gilli --- lib/path.js | 11 ----------- test/simple/test-module-nodemodulepaths.js | 3 +-- test/simple/test-path.js | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/path.js b/lib/path.js index 1765ef075d3..27c148ab535 100644 --- a/lib/path.js +++ b/lib/path.js @@ -153,12 +153,6 @@ win32.resolve = function() { resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/), !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) || '.'; }; @@ -172,11 +166,6 @@ win32.normalize = function(path) { tail = result[3], trailingSlash = /[\\\/]$/.test(tail); - // If device is a drive letter, we'll normalize to lower case. - if (device && device.charAt(1) === ':') { - device = device[0].toLowerCase() + device.substr(1); - } - // Normalize the tail path tail = normalizeArray(tail.split(/[\\\/]+/), !isAbsolute).join('\\'); diff --git a/test/simple/test-module-nodemodulepaths.js b/test/simple/test-module-nodemodulepaths.js index af44840b4b4..cf0229d541e 100644 --- a/test/simple/test-module-nodemodulepaths.js +++ b/test/simple/test-module-nodemodulepaths.js @@ -21,7 +21,6 @@ var common = require('../common'); var assert = require('assert'); -var path = require('path'); var module = require('module'); @@ -30,7 +29,7 @@ var isWindows = process.platform === 'win32'; var file, delimiter, paths; if (isWindows) { - file = path.normalize('C:\\Users\\Rocko Artischocko\\node_stuff\\foo'); + file = 'C:\\Users\\Rocko Artischocko\\node_stuff\\foo'; delimiter = '\\' } else { file = '/usr/test/lib/node_modules/npm/foo'; diff --git a/test/simple/test-path.js b/test/simple/test-path.js index cdd59bcd5d9..7a8a1b14a90 100644 --- a/test/simple/test-path.js +++ b/test/simple/test-path.js @@ -311,7 +311,7 @@ if (isWindows) { [['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'], - [['.'], path.normalize(process.cwd())], + [['.'], process.cwd()], [['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'], [['c:/', '//'], 'c:\\'], [['c:/', '//dir'], 'c:\\dir'],