Skip to content
Open
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 @@ -313,7 +313,7 @@ export class ClientCertificatesProxy {
const proxyFromOptions = createProxyAgent(this._proxy);
if (proxyFromOptions)
return proxyFromOptions;
const proxyFromEnv = getProxyForUrl(`https://${host}:${port}`);
const proxyFromEnv = getProxyForUrl(new URL(`https://${host}:${port}`));
if (proxyFromEnv)
return createProxyAgent({ server: proxyFromEnv });
}
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function httpRequest(params: HTTPRequestParams, onResponse: (r: http.Inco
if (params.rejectUnauthorized !== undefined)
options.rejectUnauthorized = params.rejectUnauthorized;

const proxyURL = getProxyForUrl(params.url);
const proxyURL = getProxyForUrl(url);
if (proxyURL) {
const parsedProxyURL = normalizeProxyURL(proxyURL);
if (params.url.startsWith('http:')) {
Expand Down
14 changes: 13 additions & 1 deletion packages/playwright-core/src/utilsBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const colors: typeof import('../bundles/utils/node_modules/colors/safe')
export const debug: typeof import('../bundles/utils/node_modules/@types/debug') = require('./utilsBundleImpl').debug;
export const diff: typeof import('../bundles/utils/node_modules/@types/diff') = require('./utilsBundleImpl').diff;
export const dotenv: typeof import('../bundles/utils/node_modules/dotenv') = require('./utilsBundleImpl').dotenv;
export const getProxyForUrl: typeof import('../bundles/utils/node_modules/@types/proxy-from-env').getProxyForUrl = require('./utilsBundleImpl').getProxyForUrl;
const getProxyForUrlFromEnv: typeof import('../bundles/utils/node_modules/@types/proxy-from-env').getProxyForUrl = require('./utilsBundleImpl').getProxyForUrl;
export const HttpsProxyAgent: typeof import('../bundles/utils/node_modules/https-proxy-agent').HttpsProxyAgent = require('./utilsBundleImpl').HttpsProxyAgent;
export const jpegjs: typeof import('../bundles/utils/node_modules/jpeg-js') = require('./utilsBundleImpl').jpegjs;
export const lockfile: typeof import('../bundles/utils/node_modules/@types/proper-lockfile') = require('./utilsBundleImpl').lockfile;
Expand All @@ -39,6 +39,18 @@ export type { Range as YAMLRange, Scalar as YAMLScalar, YAMLError, YAMLMap, YAML
export type { Command } from '../bundles/utils/node_modules/commander';
export type { EventEmitter as WebSocketEventEmitter, RawData as WebSocketRawData, WebSocket, WebSocketServer } from '../bundles/utils/node_modules/@types/ws';

// Wraps proxy-from-env's getProxyForUrl to accept a modern URL instance,
// avoiding the deprecated url.parse() call inside the library.
// It only reads a couple of fields.
export function getProxyForUrl(url: URL): string {
return getProxyForUrlFromEnv({
protocol: url.protocol,
// WHATWG URL strips default ports from hostname, which node:url doesn't, but this doesnt matter for proxy-from-env.
host: url.host,
port: url.port,
} as import('node:url').Url);
}

export function ms(ms: number): string {
if (!isFinite(ms))
return '-';
Expand Down
Loading