#13325: (feat)Normalize to pass WebSocket CDP URLs for Browser
size: XS
Cluster:
Browser Enhancements and Fixes
Add support for remote browser CDP which using WS protocol by normalize ws/wss → http/https so callers can pass WebSocket CDP URLs.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR enables users to pass WebSocket CDP URLs (`ws://`, `wss://`) as browser configuration, automatically normalizing them to HTTP/HTTPS for REST endpoint access. The normalization converts `ws:` → `http:` and `wss:` → `https:` in two locations: `parseHttpUrl()` in `src/browser/config.ts:96-106` and `parseBaseUrl()` in `src/browser/extension-relay.ts:117-138`.
**Changes:**
- Updated `parseHttpUrl()` and `parseBaseUrl()` to accept and normalize WebSocket protocols
- Added comprehensive test coverage for ws/wss URL normalization
- Updated error messages to reflect that ws(s) protocols are now accepted
- Changed test fixture from `ws://` to `ftp://` for unsupported protocol validation
The approach aligns with existing normalization patterns in the codebase (see `normalizeCdpHttpBaseForJsonEndpoints` in `src/browser/pw-session.ts:529-549`).
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is clean, follows existing patterns in the codebase, includes comprehensive test coverage for both ws and wss protocols, and correctly updates error messages. The normalization approach is consistent with similar logic already present in `pw-session.ts`.
- No files require special attention
<sub>Last reviewed commit: 3ce0867</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#17760: fix(browser): rewrite 0.0.0.0 and [::] wildcard addresses in CDP We...
by joeharouni · 2026-02-16
76.6%
#15595: fix(browser): avoid local port conflicts for remote cdp
by TsekaLuk · 2026-02-13
74.4%
#8303: fix(browser): enable downloads via CDP Browser.setDownloadBehavior
by gavinbmoore · 2026-02-03
72.6%
#9020: fix(browser): skip port ownership and WS reachability checks for re...
by yepack · 2026-02-04
70.7%
#8124: fix(browser): add path validation for file upload and download
by yubrew · 2026-02-03
70.5%
#21772: [Bug]: Allow ws:// to Tailscale CGNAT addresses
by AIflow-Labs · 2026-02-20
70.2%
#6686: fix: clear Playwright's default colorScheme override on CDP-connect...
by Terwox · 2026-02-01
70.1%
#10745: feat: Security improvements and Windows compatibility fixes
by lluviaoscuradeldoce-design · 2026-02-06
70.0%
#12075: feat(browser): session-aware context isolation for multi-agent brow...
by xiaoyaner0201 · 2026-02-08
69.6%
#13848: fix(test): normalize paths in source-display test for windows
by gengmao · 2026-02-11
69.2%