Skip to content

Commit 1a5927f

Browse files
shivanthaddaleax
authored andcommitted
repl: do not consider ... as a REPL command
This fix makes ... in REPL to be considered as a javascript construct rather than a REPL keyword. Fixes: #14426 PR-URL: #14467 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 7b6a774 commit 1a5927f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/repl.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ function REPLServer(prompt,
418418
// Check to see if a REPL keyword was used. If it returns true,
419419
// display next prompt and return.
420420
if (trimmedCmd) {
421-
if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) {
421+
if (trimmedCmd.charAt(0) === '.' && trimmedCmd.charAt(1) !== '.' &&
422+
isNaN(parseFloat(trimmedCmd))) {
422423
const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/);
423424
const keyword = matches && matches[1];
424425
const rest = matches && matches[2];

test/parallel/test-repl.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,13 @@ function error_test() {
414414
expect: `${prompt_multiline}'foo \\n'\n${prompt_unix}` },
415415
// Whitespace is not evaluated.
416416
{ client: client_unix, send: ' \t \n',
417-
expect: prompt_unix }
417+
expect: prompt_unix },
418+
// Do not parse `...[]` as a REPL keyword
419+
{ client: client_unix, send: '...[]\n',
420+
expect: `${prompt_multiline}` },
421+
// bring back the repl to prompt
422+
{ client: client_unix, send: '.break',
423+
expect: `${prompt_unix}` }
418424
]);
419425
}
420426

0 commit comments

Comments
 (0)