@@ -76,9 +76,9 @@ const {
7676 StringPrototypeCharAt,
7777 StringPrototypeEndsWith,
7878 StringPrototypeIncludes,
79- StringPrototypeIndexOf,
8079 StringPrototypeRepeat,
8180 StringPrototypeSlice,
81+ StringPrototypeSplit,
8282 StringPrototypeStartsWith,
8383 StringPrototypeTrim,
8484 Symbol,
@@ -803,24 +803,19 @@ class REPLServer extends Interface {
803803 }
804804
805805 // Check REPL keywords and empty lines against a trimmed line input.
806- const trimmedCmd = StringPrototypeTrim ( cmd ) ;
806+ let trimmedCmd = StringPrototypeTrim ( cmd ) ;
807807
808808 // Check to see if a REPL keyword was used. If it returns true,
809809 // display next prompt and return.
810810 if ( trimmedCmd ) {
811- // If condition validates for dot commands at the beginning of the line,
812- // or dot commands after some whitespace.
813- const isDotCommandAtStart = StringPrototypeCharAt ( trimmedCmd , 0 ) === '.' &&
814- StringPrototypeCharAt ( trimmedCmd , 1 ) !== '.' ;
815- const dotIndex = StringPrototypeIndexOf ( trimmedCmd , '.' ) ;
816- const isDotCommandAfterWhitespace = dotIndex > 0 &&
817- StringPrototypeCharAt ( trimmedCmd , dotIndex + 1 ) !== '.' ;
818- const matches = RegExpPrototypeExec ( / (?: ^ | \s ) \. ( [ ^ \s ] + ) \s * ( .* ) $ / , trimmedCmd ) ;
819- const keyword = matches ?. [ 1 ] ;
820- const rest = matches ?. [ 2 ] ;
821- const isValidKeyword = keyword && ObjectKeys ( self . commands ) . includes ( keyword ) ;
822- if ( ( isDotCommandAtStart || isDotCommandAfterWhitespace && isValidKeyword ) &&
823- NumberIsNaN ( NumberParseFloat ( trimmedCmd ) ) ) {
811+ const splitString = StringPrototypeSplit ( trimmedCmd , '\r' ) ;
812+ trimmedCmd = splitString [ splitString . length - 1 ] ;
813+ if ( StringPrototypeCharAt ( trimmedCmd , 0 ) === '.' &&
814+ StringPrototypeCharAt ( trimmedCmd , 1 ) !== '.' &&
815+ NumberIsNaN ( NumberParseFloat ( trimmedCmd ) ) ) {
816+ const matches = RegExpPrototypeExec ( / ^ \. ( [ ^ \s ] + ) \s * ( .* ) $ / , trimmedCmd ) ;
817+ const keyword = matches ?. [ 1 ] ;
818+ const rest = matches ?. [ 2 ] ;
824819 if ( FunctionPrototypeCall ( _parseREPLKeyword , self , keyword , rest ) === true ) {
825820 return ;
826821 }
0 commit comments