@jayfong/x-request 2.96.1 → 2.97.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.
package/lib/_cjs/index.js CHANGED
@@ -112,7 +112,7 @@ class XRequest {
112
112
  }
113
113
  if (options.proxyUrl) {
114
114
  const proxyAgent = new _proxyAgent.ProxyAgent({
115
- getProxyForUrl: () => options.proxyUrl
115
+ getProxyForUrl: typeof options.proxyUrl === 'function' ? options.proxyUrl : () => options.proxyUrl
116
116
  });
117
117
  gotOptions.agent = {
118
118
  http: proxyAgent,
package/lib/index.d.ts CHANGED
@@ -38,7 +38,7 @@ export interface XRequestOptions {
38
38
  /**
39
39
  * 代理地址
40
40
  */
41
- proxyUrl?: string;
41
+ proxyUrl?: string | ((url: string) => string);
42
42
  /**
43
43
  * 超时毫秒数
44
44
  */
package/lib/index.js CHANGED
@@ -103,7 +103,7 @@ export class XRequest {
103
103
  }
104
104
  if (options.proxyUrl) {
105
105
  const proxyAgent = new ProxyAgent({
106
- getProxyForUrl: () => options.proxyUrl
106
+ getProxyForUrl: typeof options.proxyUrl === 'function' ? options.proxyUrl : () => options.proxyUrl
107
107
  });
108
108
  gotOptions.agent = {
109
109
  http: proxyAgent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-request",
3
- "version": "2.96.1",
3
+ "version": "2.97.0",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",