Skip to content

Commit 0804e77

Browse files
fixup! fixup! debugger: fix behavior of plain object exec in debugger repl
move regexes outside of `isObjectLiteral`
1 parent 146f268 commit 0804e77

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/internal/repl/utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,9 @@ function setupReverseSearch(repl) {
739739
return { reverseSearch };
740740
}
741741

742+
const startsWithBraceRegExp = /^\s*{/;
743+
const endsWithSemicolonRegExp = /;\s*$/;
744+
742745
/**
743746
* Checks if some provided code represents an object literal.
744747
* This is helpful to prevent confusing repl code evaluations where
@@ -748,8 +751,8 @@ function setupReverseSearch(repl) {
748751
* @returns {boolean} true if the code represents an object literal, false otherwise
749752
*/
750753
function isObjectLiteral(code) {
751-
return RegExpPrototypeExec(/^\s*{/, code) !== null &&
752-
RegExpPrototypeExec(/;\s*$/, code) === null;
754+
return RegExpPrototypeExec(startsWithBraceRegExp, code) !== null &&
755+
RegExpPrototypeExec(endsWithSemicolonRegExp, code) === null;
753756
}
754757

755758
module.exports = {

0 commit comments

Comments
 (0)