Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class PlaywrightController extends BrowserController<

return {
proxy: {
server: url.origin,
server: `${url.protocol}//${url.host}`,
username,
password,
bypass: pageOptions?.proxy?.bypass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class PuppeteerController extends BrowserController<
const password = decodeURIComponent(url.password);

return {
proxyServer: url.origin,
proxyServer: `${url.protocol}//${url.host}`,
proxyUsername: username,
proxyPassword: password,
proxyBypassList: pageOptions?.proxyBypassList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class StagehandController extends BrowserController<BrowserType, LaunchOp

return {
proxy: {
server: url.origin,
server: `${url.protocol}//${url.host}`,
username,
password,
bypass: pageOptions?.proxy?.bypass,
Expand Down
32 changes: 32 additions & 0 deletions test/browser-pool/browser-plugins/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,38 @@ describe('Plugins', () => {

runPluginTest(PuppeteerPlugin, PuppeteerController, puppeteer);

describe('normalizeProxyOptions', () => {
test.each([
['socks5://user:pass@proxy.example.com:1080', 'socks5://proxy.example.com:1080'],
['http://user:pass@proxy.example.com:8080', 'http://proxy.example.com:8080'],
])('PlaywrightController should handle %s', (proxyUrl, expectedServer) => {
const plugin = new PlaywrightPlugin(playwright.chromium);
const browserController = new PlaywrightController(plugin);

const result = browserController.normalizeProxyOptions(proxyUrl, {});

expect(result).toMatchObject({
proxy: { server: expectedServer, username: 'user', password: 'pass' },
});
});

test.each([
['socks5://user:pass@proxy.example.com:1080', 'socks5://proxy.example.com:1080'],
['http://user:pass@proxy.example.com:8080', 'http://proxy.example.com:8080'],
])('PuppeteerController should handle %s', (proxyUrl, expectedServer) => {
const plugin = new PuppeteerPlugin(puppeteer);
const browserController = new PuppeteerController(plugin);

const result = browserController.normalizeProxyOptions(proxyUrl, {});

expect(result).toMatchObject({
proxyServer: expectedServer,
proxyUsername: 'user',
proxyPassword: 'pass',
});
});
});

describe('Playwright specifics', () => {
let browser: playwright.Browser;

Expand Down
Loading