Skip to content

Commit 1689500

Browse files
committed
Use @vscode/proxy-agent to resolve proxy URL
1 parent e35e3b4 commit 1689500

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/vs/platform/request/node/proxy.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,23 @@
55

66
import { parse as parseUrl, Url } from 'url';
77
import { isBoolean } from '../../../base/common/types.js';
8+
import { createProxyResolver } from '@vscode/proxy-agent';
89

910
export type Agent = any;
1011

11-
function getSystemProxyURI(requestURL: Url, env: typeof process.env): string | null {
12-
if (requestURL.protocol === 'http:') {
13-
return env.HTTP_PROXY || env.http_proxy || null;
14-
} else if (requestURL.protocol === 'https:') {
15-
return env.HTTPS_PROXY || env.https_proxy || env.HTTP_PROXY || env.http_proxy || null;
16-
}
17-
18-
return null;
19-
}
20-
2112
export interface IOptions {
2213
proxyUrl?: string;
2314
strictSSL?: boolean;
2415
}
2516

2617
export async function getProxyAgent(rawRequestURL: string, env: typeof process.env, options: IOptions = {}): Promise<Agent> {
27-
const requestURL = parseUrl(rawRequestURL);
28-
const proxyURL = options.proxyUrl || getSystemProxyURI(requestURL, env);
18+
const { resolveProxyURL } = createProxyResolver({
19+
getProxyURL: () => {
20+
return options.proxyUrl
21+
}
22+
});
2923

24+
const proxyURL = await resolveProxyURL(rawRequestURL)
3025
if (!proxyURL) {
3126
return null;
3227
}

0 commit comments

Comments
 (0)