playwright-core 1.57.0-alpha-2025-10-08 → 1.57.0-alpha-2025-10-09
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/utils/network.js +21 -17
- package/package.json +1 -1
|
@@ -58,8 +58,8 @@ function httpRequest(params, onResponse, onError) {
|
|
|
58
58
|
options.rejectUnauthorized = params.rejectUnauthorized;
|
|
59
59
|
const proxyURL = (0, import_utilsBundle.getProxyForUrl)(params.url);
|
|
60
60
|
if (proxyURL) {
|
|
61
|
-
const parsedProxyURL = import_url.default.parse(proxyURL);
|
|
62
61
|
if (params.url.startsWith("http:")) {
|
|
62
|
+
const parsedProxyURL = import_url.default.parse(proxyURL);
|
|
63
63
|
options = {
|
|
64
64
|
path: parsedUrl.href,
|
|
65
65
|
host: parsedProxyURL.hostname,
|
|
@@ -69,7 +69,7 @@ function httpRequest(params, onResponse, onError) {
|
|
|
69
69
|
method: options.method
|
|
70
70
|
};
|
|
71
71
|
} else {
|
|
72
|
-
options.agent = new import_utilsBundle.HttpsProxyAgent(
|
|
72
|
+
options.agent = new import_utilsBundle.HttpsProxyAgent(normalizeProxyURL(proxyURL));
|
|
73
73
|
options.rejectUnauthorized = false;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -134,29 +134,33 @@ function shouldBypassProxy(url2, bypass) {
|
|
|
134
134
|
const domain = "." + url2.hostname;
|
|
135
135
|
return domains.some((d) => domain.endsWith(d));
|
|
136
136
|
}
|
|
137
|
+
function normalizeProxyURL(proxy) {
|
|
138
|
+
proxy = proxy.trim();
|
|
139
|
+
if (!/^\w+:\/\//.test(proxy))
|
|
140
|
+
proxy = "http://" + proxy;
|
|
141
|
+
return new URL(proxy);
|
|
142
|
+
}
|
|
137
143
|
function createProxyAgent(proxy, forUrl) {
|
|
138
144
|
if (!proxy)
|
|
139
145
|
return;
|
|
140
146
|
if (forUrl && proxy.bypass && shouldBypassProxy(forUrl, proxy.bypass))
|
|
141
147
|
return;
|
|
142
|
-
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
const proxyURL = normalizeProxyURL(proxy.server);
|
|
149
|
+
if (proxyURL.protocol?.startsWith("socks")) {
|
|
150
|
+
if (proxyURL.protocol === "socks5:")
|
|
151
|
+
proxyURL.protocol = "socks5h:";
|
|
152
|
+
else if (proxyURL.protocol === "socks4:")
|
|
153
|
+
proxyURL.protocol = "socks4a:";
|
|
154
|
+
return new import_utilsBundle.SocksProxyAgent(proxyURL);
|
|
155
|
+
}
|
|
156
|
+
if (proxy.username) {
|
|
157
|
+
proxyURL.username = proxy.username;
|
|
158
|
+
proxyURL.password = proxy.password || "";
|
|
153
159
|
}
|
|
154
|
-
if (proxy.username)
|
|
155
|
-
proxyOpts.auth = `${proxy.username}:${proxy.password || ""}`;
|
|
156
160
|
if (forUrl && ["ws:", "wss:"].includes(forUrl.protocol)) {
|
|
157
|
-
return new import_utilsBundle.HttpsProxyAgent(
|
|
161
|
+
return new import_utilsBundle.HttpsProxyAgent(proxyURL);
|
|
158
162
|
}
|
|
159
|
-
return new import_utilsBundle.HttpsProxyAgent(
|
|
163
|
+
return new import_utilsBundle.HttpsProxyAgent(proxyURL);
|
|
160
164
|
}
|
|
161
165
|
function createHttpServer(...args) {
|
|
162
166
|
const server = import_http.default.createServer(...args);
|