Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export const cliOptions = {
description:
'Connect to a running Chrome instance using port forwarding. For more details see: https://developer.chrome.com/docs/devtools/remote-debugging/local-server.',
alias: 'u',
coerce: (url: string) => {
coerce: (url: string | undefined) => {
if (!url) {
return;
}
try {
new URL(url);
} catch {
Expand Down
19 changes: 19 additions & 0 deletions tests/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ describe('cli args parsing', () => {
});
});

it('parses an empty browser url', async () => {
const args = parseArguments('1.0.0', [
'node',
'main.js',
'--browserUrl',
'',
]);
assert.deepStrictEqual(args, {
_: [],
headless: false,
isolated: false,
$0: 'npx chrome-devtools-mcp@latest',
'browser-url': undefined,
browserUrl: undefined,
u: undefined,
channel: 'stable',
});
});

it('parses with executable path', async () => {
const args = parseArguments('1.0.0', [
'node',
Expand Down