playwright-core 1.54.0-beta-1752237221000 → 1.54.0

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.
@@ -41,14 +41,12 @@ module.exports = __toCommonJS(network_exports);
41
41
  var import_http = __toESM(require("http"));
42
42
  var import_http2 = __toESM(require("http2"));
43
43
  var import_https = __toESM(require("https"));
44
- var import_url = __toESM(require("url"));
45
44
  var import_utilsBundle = require("../../utilsBundle");
46
45
  var import_happyEyeballs = require("./happyEyeballs");
47
46
  const NET_DEFAULT_TIMEOUT = 3e4;
48
47
  function httpRequest(params, onResponse, onError) {
49
- const parsedUrl = import_url.default.parse(params.url);
50
- let options = {
51
- ...parsedUrl,
48
+ const parsedUrl = new URL(params.url);
49
+ const options = {
52
50
  agent: parsedUrl.protocol === "https:" ? import_happyEyeballs.httpsHappyEyeballsAgent : import_happyEyeballs.httpHappyEyeballsAgent,
53
51
  method: params.method || "GET",
54
52
  headers: params.headers
@@ -57,18 +55,15 @@ function httpRequest(params, onResponse, onError) {
57
55
  options.rejectUnauthorized = params.rejectUnauthorized;
58
56
  const proxyURL = (0, import_utilsBundle.getProxyForUrl)(params.url);
59
57
  if (proxyURL) {
60
- const parsedProxyURL = import_url.default.parse(proxyURL);
58
+ const parsedProxyURL = new URL(proxyURL);
61
59
  if (params.url.startsWith("http:")) {
62
- options = {
63
- path: parsedUrl.href,
64
- host: parsedProxyURL.hostname,
65
- port: parsedProxyURL.port,
66
- headers: options.headers,
67
- method: options.method
68
- };
60
+ parsedUrl.pathname = parsedUrl.href;
61
+ parsedUrl.host = parsedProxyURL.host;
69
62
  } else {
70
- parsedProxyURL.secureProxy = parsedProxyURL.protocol === "https:";
71
- options.agent = new import_utilsBundle.HttpsProxyAgent(parsedProxyURL);
63
+ options.agent = new import_utilsBundle.HttpsProxyAgent({
64
+ ...convertURLtoLegacyUrl(parsedProxyURL),
65
+ secureProxy: parsedProxyURL.protocol === "https:"
66
+ });
72
67
  options.rejectUnauthorized = false;
73
68
  }
74
69
  }
@@ -82,7 +77,7 @@ function httpRequest(params, onResponse, onError) {
82
77
  onResponse(res);
83
78
  }
84
79
  };
85
- const request = options.protocol === "https:" ? import_https.default.request(options, requestCallback) : import_http.default.request(options, requestCallback);
80
+ const request = options.protocol === "https:" ? import_https.default.request(parsedUrl, options, requestCallback) : import_http.default.request(parsedUrl, options, requestCallback);
86
81
  request.on("error", onError);
87
82
  if (params.socketTimeout !== void 0) {
88
83
  request.setTimeout(params.socketTimeout, () => {
@@ -131,19 +126,21 @@ function createProxyAgent(proxy, forUrl) {
131
126
  let proxyServer = proxy.server.trim();
132
127
  if (!/^\w+:\/\//.test(proxyServer))
133
128
  proxyServer = "http://" + proxyServer;
134
- const proxyOpts = import_url.default.parse(proxyServer);
129
+ const proxyOpts = new URL(proxyServer);
135
130
  if (proxyOpts.protocol?.startsWith("socks")) {
136
131
  return new import_utilsBundle.SocksProxyAgent({
137
132
  host: proxyOpts.hostname,
138
133
  port: proxyOpts.port || void 0
139
134
  });
140
135
  }
141
- if (proxy.username)
142
- proxyOpts.auth = `${proxy.username}:${proxy.password || ""}`;
136
+ if (proxy.username) {
137
+ proxyOpts.username = proxy.username;
138
+ proxyOpts.password = proxy.password || "";
139
+ }
143
140
  if (forUrl && ["ws:", "wss:"].includes(forUrl.protocol)) {
144
- return new import_utilsBundle.HttpsProxyAgent(proxyOpts);
141
+ return new import_utilsBundle.HttpsProxyAgent(convertURLtoLegacyUrl(proxyOpts));
145
142
  }
146
- return new import_utilsBundle.HttpsProxyAgent(proxyOpts);
143
+ return new import_utilsBundle.HttpsProxyAgent(convertURLtoLegacyUrl(proxyOpts));
147
144
  }
148
145
  function createHttpServer(...args) {
149
146
  const server = import_http.default.createServer(...args);
@@ -203,6 +200,22 @@ function decorateServer(server) {
203
200
  return close.call(server, callback);
204
201
  };
205
202
  }
203
+ function convertURLtoLegacyUrl(url2) {
204
+ return {
205
+ auth: url2.username ? url2.username + ":" + url2.password : null,
206
+ hash: url2.hash || null,
207
+ host: url2.hostname ? url2.hostname + ":" + url2.port : null,
208
+ hostname: url2.hostname || null,
209
+ href: url2.href,
210
+ path: url2.pathname + url2.search,
211
+ pathname: url2.pathname,
212
+ protocol: url2.protocol,
213
+ search: url2.search || null,
214
+ slashes: true,
215
+ port: url2.port || null,
216
+ query: url2.search.slice(1) || null
217
+ };
218
+ }
206
219
  // Annotate the CommonJS export names for ESM import in node:
207
220
  0 && (module.exports = {
208
221
  NET_DEFAULT_TIMEOUT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playwright-core",
3
- "version": "1.54.0-beta-1752237221000",
3
+ "version": "1.54.0",
4
4
  "description": "A high-level API to automate web browsers",
5
5
  "repository": {
6
6
  "type": "git",