diff --git a/lib/repl.js b/lib/repl.js index d978f27dbf0d6b..1d78a001953bf6 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -357,7 +357,7 @@ function REPLServer(prompt, } } - if (!skipCatchall) { + if (!skipCatchall && (cmd || (!cmd && self.bufferedCommand))) { var evalCmd = self.bufferedCommand + cmd; if (/^\s*\{/.test(evalCmd) && /\}\s*$/.test(evalCmd)) { // It's confusing for `{ a : 1 }` to be interpreted as a block diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 27802c782e0f4e..5829b4a52854c7 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -225,6 +225,13 @@ function error_test() { // using REPL command "help" within a string literal should still work { client: client_unix, send: '\'thefourth\\\n.help\neye\'', expect: /'thefourtheye'/ }, + // empty lines in the REPL should be allowed + { client: client_unix, send: '\n\r\n\r\n', + expect: prompt_unix + prompt_unix + prompt_unix }, + // empty lines in the string literals should not affect the string + { client: client_unix, send: '\'the\\\n\\\nfourtheye\'\n', + expect: prompt_multiline + prompt_multiline + + '\'thefourtheye\'\n' + prompt_unix }, ]); }