@@ -44,13 +44,17 @@ function isPathSeparator(code) {
4444 return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH ;
4545}
4646
47+ function isPosixPathSeparator ( code ) {
48+ return code === CHAR_FORWARD_SLASH ;
49+ }
50+
4751function isWindowsDeviceRoot ( code ) {
4852 return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z ||
4953 code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z ;
5054}
5155
5256// Resolves . and .. elements in a path with directory names
53- function normalizeString ( path , allowAboveRoot , separator ) {
57+ function normalizeString ( path , allowAboveRoot , separator , isPathSeparator ) {
5458 var res = '' ;
5559 var lastSegmentLength = 0 ;
5660 var lastSlash = - 1 ;
@@ -272,7 +276,8 @@ const win32 = {
272276 // fails)
273277
274278 // Normalize the tail path
275- resolvedTail = normalizeString ( resolvedTail , ! resolvedAbsolute , '\\' ) ;
279+ resolvedTail = normalizeString ( resolvedTail , ! resolvedAbsolute , '\\' ,
280+ isPathSeparator ) ;
276281
277282 return ( resolvedDevice + ( resolvedAbsolute ? '\\' : '' ) + resolvedTail ) ||
278283 '.' ;
@@ -363,10 +368,12 @@ const win32 = {
363368 }
364369
365370 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 {
369375 tail = '' ;
376+ }
370377 if ( tail . length === 0 && ! isAbsolute )
371378 tail = '.' ;
372379 if ( tail . length > 0 && isPathSeparator ( path . charCodeAt ( len - 1 ) ) )
@@ -1095,7 +1102,8 @@ const posix = {
10951102 // handle relative paths to be safe (might happen when process.cwd() fails)
10961103
10971104 // Normalize the path
1098- resolvedPath = normalizeString ( resolvedPath , ! resolvedAbsolute , '/' ) ;
1105+ resolvedPath = normalizeString ( resolvedPath , ! resolvedAbsolute , '/' ,
1106+ isPosixPathSeparator ) ;
10991107
11001108 if ( resolvedAbsolute ) {
11011109 if ( resolvedPath . length > 0 )
@@ -1121,7 +1129,7 @@ const posix = {
11211129 path . charCodeAt ( path . length - 1 ) === CHAR_FORWARD_SLASH ;
11221130
11231131 // Normalize the path
1124- path = normalizeString ( path , ! isAbsolute , '/' ) ;
1132+ path = normalizeString ( path , ! isAbsolute , '/' , isPosixPathSeparator ) ;
11251133
11261134 if ( path . length === 0 && ! isAbsolute )
11271135 path = '.' ;
0 commit comments