Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
path: don't lower-cases drive letters
Browse files Browse the repository at this point in the history
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
#7031, #7806 and lots of bikeshedding about
whether uppercase is the right case or lowercase.

This effectively reverts a05f973

Reviewed-by: Alexis Campailla <alexis@janeasystems.com>
Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
  • Loading branch information
piscisaureus authored and Julien Gilli committed Jan 15, 2015
1 parent 67f87a7 commit 016e084
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
11 changes: 0 additions & 11 deletions lib/path.js
Expand Up @@ -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) ||
'.';
};
Expand All @@ -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('\\');

Expand Down
3 changes: 1 addition & 2 deletions test/simple/test-module-nodemodulepaths.js
Expand Up @@ -21,7 +21,6 @@

var common = require('../common');
var assert = require('assert');
var path = require('path');

var module = require('module');

Expand All @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion test/simple/test-path.js
Expand Up @@ -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'],
Expand Down

0 comments on commit 016e084

Please sign in to comment.