Skip to content

Commit

Permalink
fix: console complete
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Nov 3, 2023
1 parent fe47558 commit d3d27c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/domains/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export function evaluate(params: any) {

let result: any
try {
if (params.throwOnSideEffect && hasSideEffect(params.expression)) {
throw EvalError('Possible side-effect in debug-evaluate')
}
result = evaluateJs(params.expression)
setGlobal('$_', result)
ret.result = objManager.wrap(result, {
Expand Down Expand Up @@ -180,6 +183,10 @@ uncaught.addListener(err => {
})
})

function hasSideEffect(code: string) {
return !/^[a-zA-Z0-9]*$/.test(code)
}

function getCallFrames(error?: Error) {
let callFrames: any[] = []
const callSites: any = error ? error.stack : stackTrace()
Expand Down

0 comments on commit d3d27c5

Please sign in to comment.