MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / resolve_ws_url

Function resolve_ws_url

src/browser.rs:9–25  ·  view source on GitHub ↗

Resolve the WebSocket URL for connecting to Chrome. Priority: 1. Explicit --ws-endpoint 2. Auto-connect via DevToolsActivePort (default)

(
    ws_endpoint: Option<&str>,
    user_data_dir: Option<&str>,
    channel: &str,
)

Source from the content-addressed store, hash-verified

7/// 1. Explicit --ws-endpoint
8/// 2. Auto-connect via DevToolsActivePort (default)
9pub fn resolve_ws_url(
10 ws_endpoint: Option<&str>,
11 user_data_dir: Option<&str>,
12 channel: &str,
13) -> Result<String> {
14 if let Some(ws) = ws_endpoint {
15 return Ok(ws.to_string());
16 }
17
18 // Auto-connect: read DevToolsActivePort from Chrome's user data directory
19 let data_dir = match user_data_dir {
20 Some(dir) => PathBuf::from(dir),
21 None => default_chrome_user_data_dir(channel)?,
22 };
23
24 read_devtools_active_port(&data_dir)
25}
26
27/// Read DevToolsActivePort file and construct the WebSocket URL.
28fn read_devtools_active_port(user_data_dir: &Path) -> Result<String> {

Callers 1

runFunction · 0.85

Calls 2

Tested by

no test coverage detected