Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(chromium): improve URL handling for WebSocket endpoint retrieval (#36098)

Zheng Xi Zhoueb5e3b37402b
diff --git a/packages/playwright-core/src/server/chromium/chromium.ts b/packages/playwright-core/src/server/chromium/chromium.ts
index 8e74b6e02d..6adef73807 100644
--- a/packages/playwright-core/src/server/chromium/chromium.ts
+++ b/packages/playwright-core/src/server/chromium/chromium.ts
@@ -368,7 +368,10 @@ async function urlToWSEndpoint(progress: Progress, endpointURL: string, headers:
if (endpointURL.startsWith('ws'))
return endpointURL;
progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
- const httpURL = endpointURL.endsWith('/') ? `${endpointURL}json/version/` : `${endpointURL}/json/version/`;
+ const url = new URL(endpointURL);
+ url.pathname += 'json/version/';
+ const httpURL = url.toString();
+
const json = await fetchData({
url: httpURL,
headers,