File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -564,15 +564,33 @@ const win32 = {
564564 }
565565
566566 // Skip normalization when reserved device names are present
567- const splitRegexp = / \\ + / ;
568- const parts = StringPrototypeSplit ( joined , splitRegexp ) ;
567+ const parts = [ ] ;
568+ let part = '' ;
569+
570+ for ( let i = 0 ; i < joined . length ; i ++ ) {
571+ if ( joined [ i ] === '\\' ) {
572+ if ( part ) parts . push ( part ) ;
573+ part = '' ;
574+ // Skip consecutive backslashes
575+ while ( i + 1 < joined . length && joined [ i + 1 ] === '\\' ) i ++ ;
576+ } else {
577+ part += joined [ i ] ;
578+ }
579+ }
580+ // Add the final part if any
581+ if ( part ) parts . push ( part ) ;
569582
570- const replaceRegexp = / \/ / g ;
583+ // Check if any part has a Windows reserved name
571584 if ( parts . some ( ( p ) => {
572585 const colonIndex = StringPrototypeIndexOf ( p , ':' ) ;
573586 return colonIndex !== - 1 && isWindowsReservedName ( p , colonIndex ) ;
574587 } ) ) {
575- return StringPrototypeReplace ( joined , replaceRegexp , '\\' ) ;
588+ // Replace forward slashes with backslashes
589+ let result = '' ;
590+ for ( let i = 0 ; i < joined . length ; i ++ ) {
591+ result += joined [ i ] === '/' ? '\\' : joined [ i ] ;
592+ }
593+ return result ;
576594 }
577595
578596 return win32 . normalize ( joined ) ;
You can’t perform that action at this time.
0 commit comments