@@ -96,7 +96,7 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
9696 StringPrototypeCharCodeAt ( res , res . length - 1 ) !== CHAR_DOT ||
9797 StringPrototypeCharCodeAt ( res , res . length - 2 ) !== CHAR_DOT ) {
9898 if ( res . length > 2 ) {
99- const lastSlashIndex = StringPrototypeLastIndexOf ( res , separator ) ;
99+ const lastSlashIndex = res . length - lastSegmentLength - 1 ;
100100 if ( lastSlashIndex === - 1 ) {
101101 res = '' ;
102102 lastSegmentLength = 0 ;
@@ -178,6 +178,7 @@ function glob(path, pattern, windows) {
178178 nocaseMagicOnly : true ,
179179 } ) ;
180180}
181+ const forwardSlashRegExp = / \/ / g;
181182
182183const win32 = {
183184 /**
@@ -202,6 +203,14 @@ const win32 = {
202203 }
203204 } else if ( resolvedDevice . length === 0 ) {
204205 path = process . cwd ( ) ;
206+ // Fast path for current directory
207+ if ( args . length === 0 || ( ( args . length === 1 && ( args [ 0 ] === '' || args [ 0 ] === '.' ) ) &&
208+ isPathSeparator ( StringPrototypeCharCodeAt ( path , 0 ) ) ) ) {
209+ if ( ! isWindows ) {
210+ path = StringPrototypeReplace ( path , forwardSlashRegExp , '\\' ) ;
211+ }
212+ return path ;
213+ }
205214 } else {
206215 // Windows has the concept of drive-specific current working
207216 // directories. If we've resolved a drive letter but not yet an
@@ -1176,6 +1185,12 @@ const posix = {
11761185 * @returns {string }
11771186 */
11781187 resolve ( ...args ) {
1188+ if ( args . length === 0 || ( args . length === 1 && ( args [ 0 ] === '' || args [ 0 ] === '.' ) ) ) {
1189+ const cwd = posixCwd ( ) ;
1190+ if ( StringPrototypeCharCodeAt ( cwd , 0 ) === CHAR_FORWARD_SLASH ) {
1191+ return cwd ;
1192+ }
1193+ }
11791194 let resolvedPath = '' ;
11801195 let resolvedAbsolute = false ;
11811196
0 commit comments