@@ -44,13 +44,17 @@ function isPathSeparator(code) {
44
44
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH ;
45
45
}
46
46
47
+ function isPosixPathSeparator ( code ) {
48
+ return code === CHAR_FORWARD_SLASH ;
49
+ }
50
+
47
51
function isWindowsDeviceRoot ( code ) {
48
52
return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z ||
49
53
code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z ;
50
54
}
51
55
52
56
// Resolves . and .. elements in a path with directory names
53
- function normalizeString ( path , allowAboveRoot , separator ) {
57
+ function normalizeString ( path , allowAboveRoot , separator , isPathSeparator ) {
54
58
var res = '' ;
55
59
var lastSegmentLength = 0 ;
56
60
var lastSlash = - 1 ;
@@ -272,7 +276,8 @@ const win32 = {
272
276
// fails)
273
277
274
278
// Normalize the tail path
275
- resolvedTail = normalizeString ( resolvedTail , ! resolvedAbsolute , '\\' ) ;
279
+ resolvedTail = normalizeString ( resolvedTail , ! resolvedAbsolute , '\\' ,
280
+ isPathSeparator ) ;
276
281
277
282
return ( resolvedDevice + ( resolvedAbsolute ? '\\' : '' ) + resolvedTail ) ||
278
283
'.' ;
@@ -363,10 +368,12 @@ const win32 = {
363
368
}
364
369
365
370
var tail ;
366
- if ( rootEnd < len )
367
- tail = normalizeString ( path . slice ( rootEnd ) , ! isAbsolute , '\\' ) ;
368
- else
371
+ if ( rootEnd < len ) {
372
+ tail = normalizeString ( path . slice ( rootEnd ) , ! isAbsolute , '\\' ,
373
+ isPathSeparator ) ;
374
+ } else {
369
375
tail = '' ;
376
+ }
370
377
if ( tail . length === 0 && ! isAbsolute )
371
378
tail = '.' ;
372
379
if ( tail . length > 0 && isPathSeparator ( path . charCodeAt ( len - 1 ) ) )
@@ -1096,7 +1103,8 @@ const posix = {
1096
1103
// handle relative paths to be safe (might happen when process.cwd() fails)
1097
1104
1098
1105
// Normalize the path
1099
- resolvedPath = normalizeString ( resolvedPath , ! resolvedAbsolute , '/' ) ;
1106
+ resolvedPath = normalizeString ( resolvedPath , ! resolvedAbsolute , '/' ,
1107
+ isPosixPathSeparator ) ;
1100
1108
1101
1109
if ( resolvedAbsolute ) {
1102
1110
if ( resolvedPath . length > 0 )
@@ -1122,7 +1130,7 @@ const posix = {
1122
1130
path . charCodeAt ( path . length - 1 ) === CHAR_FORWARD_SLASH ;
1123
1131
1124
1132
// Normalize the path
1125
- path = normalizeString ( path , ! isAbsolute , '/' ) ;
1133
+ path = normalizeString ( path , ! isAbsolute , '/' , isPosixPathSeparator ) ;
1126
1134
1127
1135
if ( path . length === 0 && ! isAbsolute )
1128
1136
path = '.' ;
0 commit comments