repl: don't interpret floating point numbers
Don't interpret floating point numbers, e.g. ".1234", as REPL commands. Fixes #4268.
This commit is contained in:
parent
13c5db9771
commit
b6e989759b
@ -206,7 +206,7 @@ function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
|
||||
|
||||
// Check to see if a REPL keyword was used. If it returns true,
|
||||
// display next prompt and return.
|
||||
if (cmd && cmd.charAt(0) === '.') {
|
||||
if (cmd && cmd.charAt(0) === '.' && cmd != parseFloat(cmd)) {
|
||||
var matches = cmd.match(/^(\.[^\s]+)\s*(.*)$/);
|
||||
var keyword = matches && matches[1];
|
||||
var rest = matches && matches[2];
|
||||
|
@ -119,6 +119,9 @@ function error_test() {
|
||||
// You can recover with the .break command
|
||||
{ client: client_unix, send: '.break',
|
||||
expect: prompt_unix },
|
||||
// Floating point numbers are not interpreted as REPL commands.
|
||||
{ client: client_unix, send: '.1234',
|
||||
expect: '0.1234' },
|
||||
// Can parse valid JSON
|
||||
{ client: client_unix, send: 'JSON.parse(\'{"valid": "json"}\');',
|
||||
expect: '{ valid: \'json\' }'},
|
||||
|
Loading…
x
Reference in New Issue
Block a user