@@ -960,21 +960,20 @@ const win32 = {
960960 }
961961 }
962962
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 ) ) {
972971 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 ) ;
973976 }
974- } else {
975- ret . name = path . slice ( startPart , startDot ) ;
976- ret . base = path . slice ( startPart , end ) ;
977- ret . ext = path . slice ( startDot , end ) ;
978977 }
979978
980979 // If the directory is the root, use the entire root as the `dir` including
@@ -1380,29 +1379,21 @@ const posix = {
13801379 }
13811380 }
13821381
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 ) ;
14011392 } 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 ) ;
14041396 }
1405- ret . ext = path . slice ( startDot , end ) ;
14061397 }
14071398
14081399 if ( startPart > 0 )
0 commit comments