diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-04-14 03:21:49 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2016-04-14 15:23:23 +0300 |
commit | 0b66b8f2d2c3aceba5e65c4b4ba428b7fabd3cb5 (patch) | |
tree | 278bc140fb9a88a13e157b1553f48f4e90ac3707 /lib | |
parent | 0b1d89f35a43c27e4aa666c41defb39e586d39f2 (diff) |
repl: don’t complete non-simple expressions
Change the regular expression that recognizes “simple” JS expressions
to requiring that the full line needs to match it.
Previously, in terms like `a().b.`, `b.` would be a partial match.
This meant that completion would evaluate `b` and either fail with
a `ReferenceError` or, if `b` was some global, return the properties
of the global `b` object.
PR-URL: https://github.com/nodejs/node/pull/6192
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/repl.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/repl.js b/lib/repl.js index 44aed66a6dd..3a96eea1366 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -647,7 +647,7 @@ ArrayStream.prototype.write = function() {}; const requireRE = /\brequire\s*\(['"](([\w\.\/-]+\/)?([\w\.\/-]*))/; const simpleExpressionRE = - /(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/; + /^\s*(([a-zA-Z_$](?:\w|\$)*)\.)*([a-zA-Z_$](?:\w|\$)*)\.?$/; function intFilter(item) { // filters out anything not starting with A-Z, a-z, $ or _ |