File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 573573 function parseMileagePasteValues ( rawText ) {
574574 const normalized = String ( rawText || "" ) . replace ( / \r \n / g, "\n" ) . replace ( / \r / g, "\n" ) ;
575575 if ( ! normalized . trim ( ) ) return { values : [ ] } ;
576+ const hasGridSeparators = normalized . includes ( "\n" ) || normalized . includes ( "\t" ) ;
577+ if ( ! hasGridSeparators ) {
578+ const spaceTokens = normalized . trim ( ) . split ( / \s + / ) . filter ( ( item ) => String ( item || "" ) . trim ( ) . length > 0 ) ;
579+ if ( spaceTokens . length > 1 ) {
580+ const values = [ ] ;
581+ for ( let idx = 0 ; idx < spaceTokens . length ; idx += 1 ) {
582+ const rawCell = String ( spaceTokens [ idx ] || "" ) . trim ( ) ;
583+ const parsed = Number . parseFloat ( rawCell . replace ( / , / g, "" ) ) ;
584+ if ( ! Number . isFinite ( parsed ) || parsed < 0 ) {
585+ return {
586+ error : `Invalid mileage "${ rawCell } " at position ${ idx + 1 } .` ,
587+ values : [ ] ,
588+ } ;
589+ }
590+ values . push ( parsed > 0 ? formatSessionValue ( parsed ) : "" ) ;
591+ }
592+ return { values } ;
593+ }
594+ }
576595 const lines = normalized . split ( "\n" ) ;
577596 while ( lines . length > 0 && ! String ( lines [ lines . length - 1 ] || "" ) . trim ( ) ) {
578597 lines . pop ( ) ;
You can’t perform that action at this time.
0 commit comments