Skip to content

Commit e6cec43

Browse files
committed
fix: guard getPageById with pageId check in evaluate_script
When pageIdRouting is true but no pageId is provided, getPageById(undefined) was called which always throws. Mirror the same guard used in index.ts: only route by pageId when both the flag is on AND a pageId is present.
1 parent 7d59313 commit e6cec43

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/tools/script.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ Example with arguments: \`(el) => {
8181
return;
8282
}
8383

84-
const mcpPage = cliArgs?.pageIdRouting
85-
? context.getPageById(request.params.pageId)
86-
: context.getSelectedMcpPage();
84+
const mcpPage =
85+
cliArgs?.pageIdRouting && request.params.pageId
86+
? context.getPageById(request.params.pageId)
87+
: context.getSelectedMcpPage();
8788
const page: Page = mcpPage.pptrPage;
8889

8990
const args: Array<JSHandle<unknown>> = [];

0 commit comments

Comments
 (0)