From 5eda66959aaacbfd0bc6b261b3199e3770136f1f Mon Sep 17 00:00:00 2001 From: Szymon Marczak <36894700+szmarczak@users.noreply.github.com> Date: Tue, 31 May 2022 14:20:58 +0200 Subject: [PATCH] fix: remove trailing proxy uri slash (#75) Co-authored-by: AndreyBykov --- src/launch-context.ts | 12 +++++++++++- test/browser-plugins/plugins.test.ts | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/launch-context.ts b/src/launch-context.ts index 1e9a788..477e5df 100644 --- a/src/launch-context.ts +++ b/src/launch-context.ts @@ -111,7 +111,17 @@ export class LaunchContext< * Use `undefined` to unset existing proxy URL. */ set proxyUrl(url: string | undefined) { - this._proxyUrl = url && new URL(url).href; + if (!url) { + return; + } + + const urlInstance = new URL(url); + urlInstance.pathname = '/'; + urlInstance.search = ''; + urlInstance.hash = ''; + + // https://www.chromium.org/developers/design-documents/network-settings/#command-line-options-for-proxy-settings + this._proxyUrl = urlInstance.href.slice(0, -1); } /** diff --git a/test/browser-plugins/plugins.test.ts b/test/browser-plugins/plugins.test.ts index 27405f0..3d94d3e 100644 --- a/test/browser-plugins/plugins.test.ts +++ b/test/browser-plugins/plugins.test.ts @@ -66,7 +66,7 @@ const runPluginTest = < id, launchOptions, browserPlugin: plugin, - _proxyUrl: proxyUrl, + _proxyUrl: proxyUrl.slice(0, -1), one: 1, useIncognitoPages: false, };