@@ -96,7 +96,7 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
96
96
StringPrototypeCharCodeAt ( res , res . length - 1 ) !== CHAR_DOT ||
97
97
StringPrototypeCharCodeAt ( res , res . length - 2 ) !== CHAR_DOT ) {
98
98
if ( res . length > 2 ) {
99
- const lastSlashIndex = StringPrototypeLastIndexOf ( res , separator ) ;
99
+ const lastSlashIndex = res . length - lastSegmentLength - 1 ;
100
100
if ( lastSlashIndex === - 1 ) {
101
101
res = '' ;
102
102
lastSegmentLength = 0 ;
@@ -178,6 +178,7 @@ function glob(path, pattern, windows) {
178
178
nocaseMagicOnly : true ,
179
179
} ) ;
180
180
}
181
+ const forwardSlashRegExp = / \/ / g;
181
182
182
183
const win32 = {
183
184
/**
@@ -202,6 +203,14 @@ const win32 = {
202
203
}
203
204
} else if ( resolvedDevice . length === 0 ) {
204
205
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
+ }
205
214
} else {
206
215
// Windows has the concept of drive-specific current working
207
216
// directories. If we've resolved a drive letter but not yet an
@@ -1176,6 +1185,12 @@ const posix = {
1176
1185
* @returns {string }
1177
1186
*/
1178
1187
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
+ }
1179
1194
let resolvedPath = '' ;
1180
1195
let resolvedAbsolute = false ;
1181
1196
0 commit comments