@e-mc/request 0.6.8 → 0.6.9

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.
Files changed (3) hide show
  1. package/index.js +2 -5
  2. package/package.json +3 -3
  3. package/util.js +3 -1
package/index.js CHANGED
@@ -1514,11 +1514,8 @@ class Request extends module_1.default {
1514
1514
  if (proxy) {
1515
1515
  const pkg = secure ? 'https-proxy-agent' : 'http-proxy-agent';
1516
1516
  try {
1517
- const { protocol, hostname: proxyname, port, username, password, href } = proxy.host;
1518
- keepAlive !== null && keepAlive !== void 0 ? keepAlive : (keepAlive = proxy.keepAlive || false);
1519
- agentTimeout !== null && agentTimeout !== void 0 ? agentTimeout : (agentTimeout = proxy.agentTimeout);
1520
- agent = require(pkg)(keepAlive || agentTimeout > 0 ? { protocol, hostname: proxyname, port, username, password, keepAlive, timeout: agentTimeout } : href);
1521
- const proxyHeaders = this[kHeaders] && getBaseHeaders(href, this[kHeaders]) || getBaseHeaders(href, HTTP.HEADERS);
1517
+ const proxyHeaders = this[kHeaders] && getBaseHeaders(proxy.host.href, this[kHeaders]) || getBaseHeaders(proxy.host.href, HTTP.HEADERS);
1518
+ agent = require(pkg)(proxy.host, typeof keepAlive === 'boolean' || agentTimeout > 0 || proxyHeaders ? { keepAlive: keepAlive !== null && keepAlive !== void 0 ? keepAlive : true, timeout: agentTimeout, headers: proxyHeaders } : undefined);
1522
1519
  if (proxyHeaders) {
1523
1520
  baseHeaders = { ...baseHeaders, ...proxyHeaders };
1524
1521
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/request",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Request constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "license": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/module": "0.6.8",
24
- "@e-mc/types": "0.6.8",
23
+ "@e-mc/module": "0.6.9",
24
+ "@e-mc/types": "0.6.9",
25
25
  "combined-stream": "^1.0.8",
26
26
  "js-yaml": "^4.1.0",
27
27
  "which": "^2.0.2"
package/util.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fromSeconds = exports.asFloat = exports.asInt = exports.trimPath = exports.isRetryable = exports.checkRetryable = exports.hasBasicAuth = exports.getBasicAuth = exports.normalizeHeaders = exports.parseHeader = void 0;
4
+ const util = require("util");
4
5
  const module_1 = require("@e-mc/module");
5
6
  const types_1 = require("@e-mc/types");
7
+ const SUPPORTED_USVSTRING = module_1.default.supported(16, 8);
6
8
  const safeInt = (value) => value >= 0 ? Math.min(value, Number.MAX_SAFE_INTEGER) : NaN;
7
9
  function parseHeader(headers, name) {
8
10
  const value = headers[name];
@@ -52,7 +54,7 @@ function getBasicAuth(username, password) {
52
54
  if ((0, types_1.isObject)(username)) {
53
55
  ({ username, password } = username);
54
56
  }
55
- return (0, types_1.isString)(username) ? encodeURIComponent(username) + ((0, types_1.isString)(password) ? ':' + encodeURIComponent(password) : '') + '@' : '';
57
+ return (0, types_1.isString)(username) ? encodeURIComponent(SUPPORTED_USVSTRING ? util.toUSVString(username) : username) + ((0, types_1.isString)(password) ? ':' + encodeURIComponent(SUPPORTED_USVSTRING ? util.toUSVString(password) : password) : '') + '@' : '';
56
58
  }
57
59
  exports.getBasicAuth = getBasicAuth;
58
60
  function hasBasicAuth(value) {