@@ -960,21 +960,20 @@ const win32 = {
960
960
}
961
961
}
962
962
963
- if ( startDot === - 1 ||
964
- end === - 1 ||
965
- // We saw a non-dot character immediately before the dot
966
- preDotState === 0 ||
967
- // The (right-most) trimmed path component is exactly '..'
968
- ( preDotState === 1 &&
969
- startDot === end - 1 &&
970
- startDot === startPart + 1 ) ) {
971
- if ( end !== - 1 ) {
963
+ if ( end !== - 1 ) {
964
+ if ( startDot === - 1 ||
965
+ // We saw a non-dot character immediately before the dot
966
+ preDotState === 0 ||
967
+ // The (right-most) trimmed path component is exactly '..'
968
+ ( preDotState === 1 &&
969
+ startDot === end - 1 &&
970
+ startDot === startPart + 1 ) ) {
972
971
ret . base = ret . name = path . slice ( startPart , end ) ;
972
+ } else {
973
+ ret . name = path . slice ( startPart , startDot ) ;
974
+ ret . base = path . slice ( startPart , end ) ;
975
+ ret . ext = path . slice ( startDot , end ) ;
973
976
}
974
- } else {
975
- ret . name = path . slice ( startPart , startDot ) ;
976
- ret . base = path . slice ( startPart , end ) ;
977
- ret . ext = path . slice ( startDot , end ) ;
978
977
}
979
978
980
979
// If the directory is the root, use the entire root as the `dir` including
@@ -1380,29 +1379,21 @@ const posix = {
1380
1379
}
1381
1380
}
1382
1381
1383
- if ( startDot === - 1 ||
1384
- end === - 1 ||
1385
- // We saw a non-dot character immediately before the dot
1386
- preDotState === 0 ||
1387
- // The (right-most) trimmed path component is exactly '..'
1388
- ( preDotState === 1 &&
1389
- startDot === end - 1 &&
1390
- startDot === startPart + 1 ) ) {
1391
- if ( end !== - 1 ) {
1392
- if ( startPart === 0 && isAbsolute )
1393
- ret . base = ret . name = path . slice ( 1 , end ) ;
1394
- else
1395
- ret . base = ret . name = path . slice ( startPart , end ) ;
1396
- }
1397
- } else {
1398
- if ( startPart === 0 && isAbsolute ) {
1399
- ret . name = path . slice ( 1 , startDot ) ;
1400
- ret . base = path . slice ( 1 , end ) ;
1382
+ if ( end !== - 1 ) {
1383
+ const start = startPart === 0 && isAbsolute ? 1 : startPart ;
1384
+ if ( startDot === - 1 ||
1385
+ // We saw a non-dot character immediately before the dot
1386
+ preDotState === 0 ||
1387
+ // The (right-most) trimmed path component is exactly '..'
1388
+ ( preDotState === 1 &&
1389
+ startDot === end - 1 &&
1390
+ startDot === startPart + 1 ) ) {
1391
+ ret . base = ret . name = path . slice ( start , end ) ;
1401
1392
} else {
1402
- ret . name = path . slice ( startPart , startDot ) ;
1403
- ret . base = path . slice ( startPart , end ) ;
1393
+ ret . name = path . slice ( start , startDot ) ;
1394
+ ret . base = path . slice ( start , end ) ;
1395
+ ret . ext = path . slice ( startDot , end ) ;
1404
1396
}
1405
- ret . ext = path . slice ( startDot , end ) ;
1406
1397
}
1407
1398
1408
1399
if ( startPart > 0 )
0 commit comments