axios 1.3.6 → 1.4.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.

Potentially problematic release.


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

@@ -1,4 +1,4 @@
1
- // Axios v1.3.6 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.4.0 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  'use strict';
3
3
 
4
4
  const FormData$1 = require('form-data');
@@ -690,6 +690,11 @@ const toJSONObject = (obj) => {
690
690
  return visit(obj, 0);
691
691
  };
692
692
 
693
+ const isAsyncFn = kindOfTest('AsyncFunction');
694
+
695
+ const isThenable = (thing) =>
696
+ thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
697
+
693
698
  const utils = {
694
699
  isArray,
695
700
  isArrayBuffer,
@@ -739,7 +744,9 @@ const utils = {
739
744
  ALPHABET,
740
745
  generateString,
741
746
  isSpecCompliantForm,
742
- toJSONObject
747
+ toJSONObject,
748
+ isAsyncFn,
749
+ isThenable
743
750
  };
744
751
 
745
752
  /**
@@ -1954,7 +1961,7 @@ function buildFullPath(baseURL, requestedURL) {
1954
1961
  return requestedURL;
1955
1962
  }
1956
1963
 
1957
- const VERSION = "1.3.6";
1964
+ const VERSION = "1.4.0";
1958
1965
 
1959
1966
  function parseProtocol(url) {
1960
1967
  const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
@@ -2424,6 +2431,21 @@ class ZlibHeaderTransformStream extends stream__default["default"].Transform {
2424
2431
 
2425
2432
  const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
2426
2433
 
2434
+ const callbackify = (fn, reducer) => {
2435
+ return utils.isAsyncFn(fn) ? function (...args) {
2436
+ const cb = args.pop();
2437
+ fn.apply(this, args).then((value) => {
2438
+ try {
2439
+ reducer ? cb(null, ...reducer(value)) : cb(null, value);
2440
+ } catch (err) {
2441
+ cb(err);
2442
+ }
2443
+ }, cb);
2444
+ } : fn;
2445
+ };
2446
+
2447
+ const callbackify$1 = callbackify;
2448
+
2427
2449
  const zlibOptions = {
2428
2450
  flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
2429
2451
  finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
@@ -2546,13 +2568,24 @@ const wrapAsync = (asyncExecutor) => {
2546
2568
  /*eslint consistent-return:0*/
2547
2569
  const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2548
2570
  return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
2549
- let {data} = config;
2571
+ let {data, lookup, family} = config;
2550
2572
  const {responseType, responseEncoding} = config;
2551
2573
  const method = config.method.toUpperCase();
2552
2574
  let isDone;
2553
2575
  let rejected = false;
2554
2576
  let req;
2555
2577
 
2578
+ if (lookup && utils.isAsyncFn(lookup)) {
2579
+ lookup = callbackify$1(lookup, (entry) => {
2580
+ if(utils.isString(entry)) {
2581
+ entry = [entry, entry.indexOf('.') < 0 ? 6 : 4];
2582
+ } else if (!utils.isArray(entry)) {
2583
+ throw new TypeError('lookup async function must return an array [ip: string, family: number]]')
2584
+ }
2585
+ return entry;
2586
+ });
2587
+ }
2588
+
2556
2589
  // temporary internal emitter until the AxiosRequest class will be implemented
2557
2590
  const emitter = new EventEmitter__default["default"]();
2558
2591
 
@@ -2776,6 +2809,8 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
2776
2809
  agents: { http: config.httpAgent, https: config.httpsAgent },
2777
2810
  auth,
2778
2811
  protocol,
2812
+ family,
2813
+ lookup,
2779
2814
  beforeRedirect: dispatchBeforeRedirect,
2780
2815
  beforeRedirects: {}
2781
2816
  };
@@ -3205,8 +3240,12 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
3205
3240
  }
3206
3241
  }
3207
3242
 
3208
- if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
3209
- requestHeaders.setContentType(false); // Let the browser set it
3243
+ if (utils.isFormData(requestData)) {
3244
+ if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
3245
+ requestHeaders.setContentType(false); // Let the browser set it
3246
+ } else {
3247
+ requestHeaders.setContentType('multipart/form-data;', false); // mobile/desktop app frameworks
3248
+ }
3210
3249
  }
3211
3250
 
3212
3251
  let request = new XMLHttpRequest();
@@ -3612,7 +3651,7 @@ function mergeConfig(config1, config2) {
3612
3651
  headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
3613
3652
  };
3614
3653
 
3615
- utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
3654
+ utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
3616
3655
  const merge = mergeMap[prop] || mergeDeepProperties;
3617
3656
  const configValue = merge(config1[prop], config2[prop], prop);
3618
3657
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);