(url: string, options: OpenBrowserOptions)
| 41 | * Pure function — easy to unit-test without mocking `spawn` or `import("open")`. |
| 42 | */ |
| 43 | export function buildBrowserArgs(url: string, options: OpenBrowserOptions): string[] { |
| 44 | const args: string[] = []; |
| 45 | if (options.userDataDir) { |
| 46 | args.push(`--user-data-dir=${options.userDataDir}`); |
| 47 | } |
| 48 | // Defense-in-depth: only emit --remote-debugging-port when paired with an |
| 49 | // isolated --user-data-dir. Without an isolated profile the CDP endpoint |
| 50 | // would expose the user's main browser session, which is the whole reason |
| 51 | // the CLI validation layer requires both flags together. |
| 52 | if (options.remoteDebuggingPort !== undefined && options.userDataDir) { |
| 53 | args.push(`--remote-debugging-port=${options.remoteDebuggingPort}`); |
| 54 | } |
| 55 | args.push(url); |
| 56 | return args; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Open a URL in the browser with the given options. |
no outgoing calls
no test coverage detected