axios 1.3.0 → 1.3.2

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

@@ -7,6 +7,7 @@ import buildURL from './../helpers/buildURL.js';
7
7
  import {getProxyForUrl} from 'proxy-from-env';
8
8
  import http from 'http';
9
9
  import https from 'https';
10
+ import util from 'util';
10
11
  import followRedirects from 'follow-redirects';
11
12
  import zlib from 'zlib';
12
13
  import {VERSION} from '../env/data.js';
@@ -117,7 +118,8 @@ const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(pr
117
118
 
118
119
  /*eslint consistent-return:0*/
119
120
  export default isHttpAdapterSupported && function httpAdapter(config) {
120
- return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
121
+ /*eslint no-async-promise-executor:0*/
122
+ return new Promise(async function dispatchHttpRequest(resolvePromise, rejectPromise) {
121
123
  let data = config.data;
122
124
  const responseType = config.responseType;
123
125
  const responseEncoding = config.responseEncoding;
@@ -181,7 +183,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
181
183
 
182
184
  // Parse url
183
185
  const fullPath = buildFullPath(config.baseURL, config.url);
184
- const parsed = new URL(fullPath);
186
+ const parsed = new URL(fullPath, 'http://localhost');
185
187
  const protocol = parsed.protocol || supportedProtocols[0];
186
188
 
187
189
  if (protocol === 'data:') {
@@ -208,7 +210,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
208
210
  convertedData = convertedData.toString(responseEncoding);
209
211
 
210
212
  if (!responseEncoding || responseEncoding === 'utf8') {
211
- data = utils.stripBOM(convertedData);
213
+ convertedData = utils.stripBOM(convertedData);
212
214
  }
213
215
  } else if (responseType === 'stream') {
214
216
  convertedData = stream.Readable.from(convertedData);
@@ -258,9 +260,14 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
258
260
  // support for https://www.npmjs.com/package/form-data api
259
261
  } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
260
262
  headers.set(data.getHeaders());
261
- if (utils.isFunction(data.getLengthSync)) { // check if the undocumented API exists
262
- const knownLength = data.getLengthSync();
263
- !utils.isUndefined(knownLength) && headers.setContentLength(knownLength, false);
263
+
264
+ if (!headers.hasContentLength()) {
265
+ try {
266
+ const knownLength = await util.promisify(data.getLength).call(data);
267
+ headers.setContentLength(knownLength);
268
+ /*eslint no-empty:0*/
269
+ } catch (e) {
270
+ }
264
271
  }
265
272
  } else if (utils.isBlob(data)) {
266
273
  data.size && headers.setContentType(data.type || 'application/octet-stream');
@@ -141,7 +141,7 @@ class AxiosHeaders {
141
141
  if (header) {
142
142
  const key = utils.findKey(this, header);
143
143
 
144
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
144
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
145
145
  }
146
146
 
147
147
  return false;
package/lib/env/data.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.3.0";
1
+ export const VERSION = "1.3.2";
@@ -1,3 +1,4 @@
1
+ import {TextEncoder} from 'util';
1
2
  import {Readable} from 'stream';
2
3
  import utils from "../utils.js";
3
4
  import readBlob from "./readBlob.js";
@@ -152,7 +152,7 @@ function toFormData(obj, formData, options) {
152
152
  value = JSON.stringify(value);
153
153
  } else if (
154
154
  (utils.isArray(value) && isFlatArray(value)) ||
155
- (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
155
+ ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
156
156
  )) {
157
157
  // eslint-disable-next-line no-param-reassign
158
158
  key = removeBrackets(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axios",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Promise based HTTP client for the browser and node.js",
5
5
  "main": "index.js",
6
6
  "exports": {