axios 1.6.7 → 1.7.3

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.

package/dist/esm/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.6.7 Copyright (c) 2024 Matt Zabriskie and contributors
1
+ // Axios v1.7.3 Copyright (c) 2024 Matt Zabriskie and contributors
2
2
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -212,6 +212,8 @@ const isFormData = (thing) => {
212
212
  */
213
213
  const isURLSearchParams = kindOfTest('URLSearchParams');
214
214
 
215
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
216
+
215
217
  /**
216
218
  * Trim excess whitespace off the beginning and end of a string
217
219
  *
@@ -600,8 +602,7 @@ const toObjectSet = (arrayOrString, delimiter) => {
600
602
  const noop = () => {};
601
603
 
602
604
  const toFiniteNumber = (value, defaultValue) => {
603
- value = +value;
604
- return Number.isFinite(value) ? value : defaultValue;
605
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
605
606
  };
606
607
 
607
608
  const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
@@ -671,6 +672,36 @@ const isAsyncFn = kindOfTest('AsyncFunction');
671
672
  const isThenable = (thing) =>
672
673
  thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
673
674
 
675
+ // original code
676
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
677
+
678
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
679
+ if (setImmediateSupported) {
680
+ return setImmediate;
681
+ }
682
+
683
+ return postMessageSupported ? ((token, callbacks) => {
684
+ _global.addEventListener("message", ({source, data}) => {
685
+ if (source === _global && data === token) {
686
+ callbacks.length && callbacks.shift()();
687
+ }
688
+ }, false);
689
+
690
+ return (cb) => {
691
+ callbacks.push(cb);
692
+ _global.postMessage(token, "*");
693
+ }
694
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
695
+ })(
696
+ typeof setImmediate === 'function',
697
+ isFunction(_global.postMessage)
698
+ );
699
+
700
+ const asap = typeof queueMicrotask !== 'undefined' ?
701
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
702
+
703
+ // *********************
704
+
674
705
  const utils$1 = {
675
706
  isArray,
676
707
  isArrayBuffer,
@@ -682,6 +713,10 @@ const utils$1 = {
682
713
  isBoolean,
683
714
  isObject,
684
715
  isPlainObject,
716
+ isReadableStream,
717
+ isRequest,
718
+ isResponse,
719
+ isHeaders,
685
720
  isUndefined,
686
721
  isDate,
687
722
  isFile,
@@ -722,7 +757,9 @@ const utils$1 = {
722
757
  isSpecCompliantForm,
723
758
  toJSONObject,
724
759
  isAsyncFn,
725
- isThenable
760
+ isThenable,
761
+ setImmediate: _setImmediate,
762
+ asap
726
763
  };
727
764
 
728
765
  /**
@@ -1278,11 +1315,14 @@ const hasStandardBrowserWebWorkerEnv = (() => {
1278
1315
  );
1279
1316
  })();
1280
1317
 
1318
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1319
+
1281
1320
  const utils = /*#__PURE__*/Object.freeze({
1282
1321
  __proto__: null,
1283
1322
  hasBrowserEnv: hasBrowserEnv,
1284
1323
  hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1285
- hasStandardBrowserEnv: hasStandardBrowserEnv
1324
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1325
+ origin: origin
1286
1326
  });
1287
1327
 
1288
1328
  const platform = {
@@ -1422,7 +1462,7 @@ const defaults = {
1422
1462
 
1423
1463
  transitional: transitionalDefaults,
1424
1464
 
1425
- adapter: ['xhr', 'http'],
1465
+ adapter: ['xhr', 'http', 'fetch'],
1426
1466
 
1427
1467
  transformRequest: [function transformRequest(data, headers) {
1428
1468
  const contentType = headers.getContentType() || '';
@@ -1443,7 +1483,8 @@ const defaults = {
1443
1483
  utils$1.isBuffer(data) ||
1444
1484
  utils$1.isStream(data) ||
1445
1485
  utils$1.isFile(data) ||
1446
- utils$1.isBlob(data)
1486
+ utils$1.isBlob(data) ||
1487
+ utils$1.isReadableStream(data)
1447
1488
  ) {
1448
1489
  return data;
1449
1490
  }
@@ -1486,6 +1527,10 @@ const defaults = {
1486
1527
  const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1487
1528
  const JSONRequested = this.responseType === 'json';
1488
1529
 
1530
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1531
+ return data;
1532
+ }
1533
+
1489
1534
  if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1490
1535
  const silentJSONParsing = transitional && transitional.silentJSONParsing;
1491
1536
  const strictJSONParsing = !silentJSONParsing && JSONRequested;
@@ -1689,6 +1734,10 @@ class AxiosHeaders$1 {
1689
1734
  setHeaders(header, valueOrRewrite);
1690
1735
  } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1691
1736
  setHeaders(parseHeaders(header), valueOrRewrite);
1737
+ } else if (utils$1.isHeaders(header)) {
1738
+ for (const [key, value] of header.entries()) {
1739
+ setHeader(value, key, rewrite);
1740
+ }
1692
1741
  } else {
1693
1742
  header != null && setHeader(valueOrRewrite, header, rewrite);
1694
1743
  }
@@ -1956,90 +2005,147 @@ function settle(resolve, reject, response) {
1956
2005
  }
1957
2006
  }
1958
2007
 
1959
- const cookies = platform.hasStandardBrowserEnv ?
2008
+ function parseProtocol(url) {
2009
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2010
+ return match && match[1] || '';
2011
+ }
1960
2012
 
1961
- // Standard browser envs support document.cookie
1962
- {
1963
- write(name, value, expires, path, domain, secure) {
1964
- const cookie = [name + '=' + encodeURIComponent(value)];
2013
+ /**
2014
+ * Calculate data maxRate
2015
+ * @param {Number} [samplesCount= 10]
2016
+ * @param {Number} [min= 1000]
2017
+ * @returns {Function}
2018
+ */
2019
+ function speedometer(samplesCount, min) {
2020
+ samplesCount = samplesCount || 10;
2021
+ const bytes = new Array(samplesCount);
2022
+ const timestamps = new Array(samplesCount);
2023
+ let head = 0;
2024
+ let tail = 0;
2025
+ let firstSampleTS;
1965
2026
 
1966
- utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2027
+ min = min !== undefined ? min : 1000;
1967
2028
 
1968
- utils$1.isString(path) && cookie.push('path=' + path);
2029
+ return function push(chunkLength) {
2030
+ const now = Date.now();
1969
2031
 
1970
- utils$1.isString(domain) && cookie.push('domain=' + domain);
2032
+ const startedAt = timestamps[tail];
1971
2033
 
1972
- secure === true && cookie.push('secure');
2034
+ if (!firstSampleTS) {
2035
+ firstSampleTS = now;
2036
+ }
1973
2037
 
1974
- document.cookie = cookie.join('; ');
1975
- },
2038
+ bytes[head] = chunkLength;
2039
+ timestamps[head] = now;
1976
2040
 
1977
- read(name) {
1978
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1979
- return (match ? decodeURIComponent(match[3]) : null);
1980
- },
2041
+ let i = tail;
2042
+ let bytesCount = 0;
1981
2043
 
1982
- remove(name) {
1983
- this.write(name, '', Date.now() - 86400000);
2044
+ while (i !== head) {
2045
+ bytesCount += bytes[i++];
2046
+ i = i % samplesCount;
1984
2047
  }
1985
- }
1986
2048
 
1987
- :
2049
+ head = (head + 1) % samplesCount;
1988
2050
 
1989
- // Non-standard browser env (web workers, react-native) lack needed support.
1990
- {
1991
- write() {},
1992
- read() {
1993
- return null;
1994
- },
1995
- remove() {}
1996
- };
2051
+ if (head === tail) {
2052
+ tail = (tail + 1) % samplesCount;
2053
+ }
1997
2054
 
1998
- /**
1999
- * Determines whether the specified URL is absolute
2000
- *
2001
- * @param {string} url The URL to test
2002
- *
2003
- * @returns {boolean} True if the specified URL is absolute, otherwise false
2004
- */
2005
- function isAbsoluteURL(url) {
2006
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2007
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2008
- // by any combination of letters, digits, plus, period, or hyphen.
2009
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2010
- }
2055
+ if (now - firstSampleTS < min) {
2056
+ return;
2057
+ }
2011
2058
 
2012
- /**
2013
- * Creates a new URL by combining the specified URLs
2014
- *
2015
- * @param {string} baseURL The base URL
2016
- * @param {string} relativeURL The relative URL
2017
- *
2018
- * @returns {string} The combined URL
2019
- */
2020
- function combineURLs(baseURL, relativeURL) {
2021
- return relativeURL
2022
- ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2023
- : baseURL;
2059
+ const passed = startedAt && now - startedAt;
2060
+
2061
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2062
+ };
2024
2063
  }
2025
2064
 
2026
2065
  /**
2027
- * Creates a new URL by combining the baseURL with the requestedURL,
2028
- * only when the requestedURL is not already an absolute URL.
2029
- * If the requestURL is absolute, this function returns the requestedURL untouched.
2030
- *
2031
- * @param {string} baseURL The base URL
2032
- * @param {string} requestedURL Absolute or relative URL to combine
2033
- *
2034
- * @returns {string} The combined full path
2066
+ * Throttle decorator
2067
+ * @param {Function} fn
2068
+ * @param {Number} freq
2069
+ * @return {Function}
2035
2070
  */
2036
- function buildFullPath(baseURL, requestedURL) {
2037
- if (baseURL && !isAbsoluteURL(requestedURL)) {
2038
- return combineURLs(baseURL, requestedURL);
2039
- }
2040
- return requestedURL;
2071
+ function throttle(fn, freq) {
2072
+ let timestamp = 0;
2073
+ let threshold = 1000 / freq;
2074
+ let lastArgs;
2075
+ let timer;
2076
+
2077
+ const invoke = (args, now = Date.now()) => {
2078
+ timestamp = now;
2079
+ lastArgs = null;
2080
+ if (timer) {
2081
+ clearTimeout(timer);
2082
+ timer = null;
2083
+ }
2084
+ fn.apply(null, args);
2085
+ };
2086
+
2087
+ const throttled = (...args) => {
2088
+ const now = Date.now();
2089
+ const passed = now - timestamp;
2090
+ if ( passed >= threshold) {
2091
+ invoke(args, now);
2092
+ } else {
2093
+ lastArgs = args;
2094
+ if (!timer) {
2095
+ timer = setTimeout(() => {
2096
+ timer = null;
2097
+ invoke(lastArgs);
2098
+ }, threshold - passed);
2099
+ }
2100
+ }
2101
+ };
2102
+
2103
+ const flush = () => lastArgs && invoke(lastArgs);
2104
+
2105
+ return [throttled, flush];
2041
2106
  }
2042
2107
 
2108
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2109
+ let bytesNotified = 0;
2110
+ const _speedometer = speedometer(50, 250);
2111
+
2112
+ return throttle(e => {
2113
+ const loaded = e.loaded;
2114
+ const total = e.lengthComputable ? e.total : undefined;
2115
+ const progressBytes = loaded - bytesNotified;
2116
+ const rate = _speedometer(progressBytes);
2117
+ const inRange = loaded <= total;
2118
+
2119
+ bytesNotified = loaded;
2120
+
2121
+ const data = {
2122
+ loaded,
2123
+ total,
2124
+ progress: total ? (loaded / total) : undefined,
2125
+ bytes: progressBytes,
2126
+ rate: rate ? rate : undefined,
2127
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2128
+ event: e,
2129
+ lengthComputable: total != null,
2130
+ [isDownloadStream ? 'download' : 'upload']: true
2131
+ };
2132
+
2133
+ listener(data);
2134
+ }, freq);
2135
+ };
2136
+
2137
+ const progressEventDecorator = (total, throttled) => {
2138
+ const lengthComputable = total != null;
2139
+
2140
+ return [(loaded) => throttled[0]({
2141
+ lengthComputable,
2142
+ total,
2143
+ loaded
2144
+ }), throttled[1]];
2145
+ };
2146
+
2147
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2148
+
2043
2149
  const isURLSameOrigin = platform.hasStandardBrowserEnv ?
2044
2150
 
2045
2151
  // Standard browser envs have full support of the APIs needed to test
@@ -2103,137 +2209,267 @@ const isURLSameOrigin = platform.hasStandardBrowserEnv ?
2103
2209
  };
2104
2210
  })();
2105
2211
 
2106
- function parseProtocol(url) {
2107
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2108
- return match && match[1] || '';
2109
- }
2212
+ const cookies = platform.hasStandardBrowserEnv ?
2110
2213
 
2111
- /**
2112
- * Calculate data maxRate
2113
- * @param {Number} [samplesCount= 10]
2114
- * @param {Number} [min= 1000]
2115
- * @returns {Function}
2116
- */
2117
- function speedometer(samplesCount, min) {
2118
- samplesCount = samplesCount || 10;
2119
- const bytes = new Array(samplesCount);
2120
- const timestamps = new Array(samplesCount);
2121
- let head = 0;
2122
- let tail = 0;
2123
- let firstSampleTS;
2214
+ // Standard browser envs support document.cookie
2215
+ {
2216
+ write(name, value, expires, path, domain, secure) {
2217
+ const cookie = [name + '=' + encodeURIComponent(value)];
2124
2218
 
2125
- min = min !== undefined ? min : 1000;
2219
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2126
2220
 
2127
- return function push(chunkLength) {
2128
- const now = Date.now();
2221
+ utils$1.isString(path) && cookie.push('path=' + path);
2129
2222
 
2130
- const startedAt = timestamps[tail];
2223
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2131
2224
 
2132
- if (!firstSampleTS) {
2133
- firstSampleTS = now;
2134
- }
2225
+ secure === true && cookie.push('secure');
2135
2226
 
2136
- bytes[head] = chunkLength;
2137
- timestamps[head] = now;
2227
+ document.cookie = cookie.join('; ');
2228
+ },
2138
2229
 
2139
- let i = tail;
2140
- let bytesCount = 0;
2230
+ read(name) {
2231
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2232
+ return (match ? decodeURIComponent(match[3]) : null);
2233
+ },
2141
2234
 
2142
- while (i !== head) {
2143
- bytesCount += bytes[i++];
2144
- i = i % samplesCount;
2235
+ remove(name) {
2236
+ this.write(name, '', Date.now() - 86400000);
2145
2237
  }
2238
+ }
2146
2239
 
2147
- head = (head + 1) % samplesCount;
2148
-
2149
- if (head === tail) {
2150
- tail = (tail + 1) % samplesCount;
2151
- }
2240
+ :
2152
2241
 
2153
- if (now - firstSampleTS < min) {
2154
- return;
2155
- }
2242
+ // Non-standard browser env (web workers, react-native) lack needed support.
2243
+ {
2244
+ write() {},
2245
+ read() {
2246
+ return null;
2247
+ },
2248
+ remove() {}
2249
+ };
2156
2250
 
2157
- const passed = startedAt && now - startedAt;
2251
+ /**
2252
+ * Determines whether the specified URL is absolute
2253
+ *
2254
+ * @param {string} url The URL to test
2255
+ *
2256
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2257
+ */
2258
+ function isAbsoluteURL(url) {
2259
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2260
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2261
+ // by any combination of letters, digits, plus, period, or hyphen.
2262
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2263
+ }
2158
2264
 
2159
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2160
- };
2265
+ /**
2266
+ * Creates a new URL by combining the specified URLs
2267
+ *
2268
+ * @param {string} baseURL The base URL
2269
+ * @param {string} relativeURL The relative URL
2270
+ *
2271
+ * @returns {string} The combined URL
2272
+ */
2273
+ function combineURLs(baseURL, relativeURL) {
2274
+ return relativeURL
2275
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2276
+ : baseURL;
2161
2277
  }
2162
2278
 
2163
- function progressEventReducer(listener, isDownloadStream) {
2164
- let bytesNotified = 0;
2165
- const _speedometer = speedometer(50, 250);
2279
+ /**
2280
+ * Creates a new URL by combining the baseURL with the requestedURL,
2281
+ * only when the requestedURL is not already an absolute URL.
2282
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2283
+ *
2284
+ * @param {string} baseURL The base URL
2285
+ * @param {string} requestedURL Absolute or relative URL to combine
2286
+ *
2287
+ * @returns {string} The combined full path
2288
+ */
2289
+ function buildFullPath(baseURL, requestedURL) {
2290
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
2291
+ return combineURLs(baseURL, requestedURL);
2292
+ }
2293
+ return requestedURL;
2294
+ }
2166
2295
 
2167
- return e => {
2168
- const loaded = e.loaded;
2169
- const total = e.lengthComputable ? e.total : undefined;
2170
- const progressBytes = loaded - bytesNotified;
2171
- const rate = _speedometer(progressBytes);
2172
- const inRange = loaded <= total;
2296
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? { ...thing } : thing;
2173
2297
 
2174
- bytesNotified = loaded;
2298
+ /**
2299
+ * Config-specific merge-function which creates a new config-object
2300
+ * by merging two configuration objects together.
2301
+ *
2302
+ * @param {Object} config1
2303
+ * @param {Object} config2
2304
+ *
2305
+ * @returns {Object} New object resulting from merging config2 to config1
2306
+ */
2307
+ function mergeConfig$1(config1, config2) {
2308
+ // eslint-disable-next-line no-param-reassign
2309
+ config2 = config2 || {};
2310
+ const config = {};
2175
2311
 
2176
- const data = {
2177
- loaded,
2178
- total,
2179
- progress: total ? (loaded / total) : undefined,
2180
- bytes: progressBytes,
2181
- rate: rate ? rate : undefined,
2182
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2183
- event: e
2184
- };
2312
+ function getMergedValue(target, source, caseless) {
2313
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2314
+ return utils$1.merge.call({caseless}, target, source);
2315
+ } else if (utils$1.isPlainObject(source)) {
2316
+ return utils$1.merge({}, source);
2317
+ } else if (utils$1.isArray(source)) {
2318
+ return source.slice();
2319
+ }
2320
+ return source;
2321
+ }
2322
+
2323
+ // eslint-disable-next-line consistent-return
2324
+ function mergeDeepProperties(a, b, caseless) {
2325
+ if (!utils$1.isUndefined(b)) {
2326
+ return getMergedValue(a, b, caseless);
2327
+ } else if (!utils$1.isUndefined(a)) {
2328
+ return getMergedValue(undefined, a, caseless);
2329
+ }
2330
+ }
2185
2331
 
2186
- data[isDownloadStream ? 'download' : 'upload'] = true;
2332
+ // eslint-disable-next-line consistent-return
2333
+ function valueFromConfig2(a, b) {
2334
+ if (!utils$1.isUndefined(b)) {
2335
+ return getMergedValue(undefined, b);
2336
+ }
2337
+ }
2187
2338
 
2188
- listener(data);
2339
+ // eslint-disable-next-line consistent-return
2340
+ function defaultToConfig2(a, b) {
2341
+ if (!utils$1.isUndefined(b)) {
2342
+ return getMergedValue(undefined, b);
2343
+ } else if (!utils$1.isUndefined(a)) {
2344
+ return getMergedValue(undefined, a);
2345
+ }
2346
+ }
2347
+
2348
+ // eslint-disable-next-line consistent-return
2349
+ function mergeDirectKeys(a, b, prop) {
2350
+ if (prop in config2) {
2351
+ return getMergedValue(a, b);
2352
+ } else if (prop in config1) {
2353
+ return getMergedValue(undefined, a);
2354
+ }
2355
+ }
2356
+
2357
+ const mergeMap = {
2358
+ url: valueFromConfig2,
2359
+ method: valueFromConfig2,
2360
+ data: valueFromConfig2,
2361
+ baseURL: defaultToConfig2,
2362
+ transformRequest: defaultToConfig2,
2363
+ transformResponse: defaultToConfig2,
2364
+ paramsSerializer: defaultToConfig2,
2365
+ timeout: defaultToConfig2,
2366
+ timeoutMessage: defaultToConfig2,
2367
+ withCredentials: defaultToConfig2,
2368
+ withXSRFToken: defaultToConfig2,
2369
+ adapter: defaultToConfig2,
2370
+ responseType: defaultToConfig2,
2371
+ xsrfCookieName: defaultToConfig2,
2372
+ xsrfHeaderName: defaultToConfig2,
2373
+ onUploadProgress: defaultToConfig2,
2374
+ onDownloadProgress: defaultToConfig2,
2375
+ decompress: defaultToConfig2,
2376
+ maxContentLength: defaultToConfig2,
2377
+ maxBodyLength: defaultToConfig2,
2378
+ beforeRedirect: defaultToConfig2,
2379
+ transport: defaultToConfig2,
2380
+ httpAgent: defaultToConfig2,
2381
+ httpsAgent: defaultToConfig2,
2382
+ cancelToken: defaultToConfig2,
2383
+ socketPath: defaultToConfig2,
2384
+ responseEncoding: defaultToConfig2,
2385
+ validateStatus: mergeDirectKeys,
2386
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2189
2387
  };
2388
+
2389
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2390
+ const merge = mergeMap[prop] || mergeDeepProperties;
2391
+ const configValue = merge(config1[prop], config2[prop], prop);
2392
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2393
+ });
2394
+
2395
+ return config;
2190
2396
  }
2191
2397
 
2192
- const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2398
+ const resolveConfig = (config) => {
2399
+ const newConfig = mergeConfig$1({}, config);
2193
2400
 
2194
- const xhrAdapter = isXHRAdapterSupported && function (config) {
2195
- return new Promise(function dispatchXhrRequest(resolve, reject) {
2196
- let requestData = config.data;
2197
- const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
2198
- let {responseType, withXSRFToken} = config;
2199
- let onCanceled;
2200
- function done() {
2201
- if (config.cancelToken) {
2202
- config.cancelToken.unsubscribe(onCanceled);
2203
- }
2401
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
2204
2402
 
2205
- if (config.signal) {
2206
- config.signal.removeEventListener('abort', onCanceled);
2207
- }
2403
+ newConfig.headers = headers = AxiosHeaders$2.from(headers);
2404
+
2405
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
2406
+
2407
+ // HTTP basic authentication
2408
+ if (auth) {
2409
+ headers.set('Authorization', 'Basic ' +
2410
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2411
+ );
2412
+ }
2413
+
2414
+ let contentType;
2415
+
2416
+ if (utils$1.isFormData(data)) {
2417
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2418
+ headers.setContentType(undefined); // Let the browser set it
2419
+ } else if ((contentType = headers.getContentType()) !== false) {
2420
+ // fix semicolon duplication issue for ReactNative FormData implementation
2421
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2422
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2208
2423
  }
2424
+ }
2209
2425
 
2210
- let contentType;
2426
+ // Add xsrf header
2427
+ // This is only done if running in a standard browser environment.
2428
+ // Specifically not if we're in a web worker, or react-native.
2211
2429
 
2212
- if (utils$1.isFormData(requestData)) {
2213
- if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2214
- requestHeaders.setContentType(false); // Let the browser set it
2215
- } else if ((contentType = requestHeaders.getContentType()) !== false) {
2216
- // fix semicolon duplication issue for ReactNative FormData implementation
2217
- const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2218
- requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2430
+ if (platform.hasStandardBrowserEnv) {
2431
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2432
+
2433
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2434
+ // Add xsrf header
2435
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2436
+
2437
+ if (xsrfValue) {
2438
+ headers.set(xsrfHeaderName, xsrfValue);
2219
2439
  }
2220
2440
  }
2441
+ }
2221
2442
 
2222
- let request = new XMLHttpRequest();
2443
+ return newConfig;
2444
+ };
2445
+
2446
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2447
+
2448
+ const xhrAdapter = isXHRAdapterSupported && function (config) {
2449
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2450
+ const _config = resolveConfig(config);
2451
+ let requestData = _config.data;
2452
+ const requestHeaders = AxiosHeaders$2.from(_config.headers).normalize();
2453
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
2454
+ let onCanceled;
2455
+ let uploadThrottled, downloadThrottled;
2456
+ let flushUpload, flushDownload;
2457
+
2458
+ function done() {
2459
+ flushUpload && flushUpload(); // flush events
2460
+ flushDownload && flushDownload(); // flush events
2461
+
2462
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2223
2463
 
2224
- // HTTP basic authentication
2225
- if (config.auth) {
2226
- const username = config.auth.username || '';
2227
- const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2228
- requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2464
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2229
2465
  }
2230
2466
 
2231
- const fullPath = buildFullPath(config.baseURL, config.url);
2467
+ let request = new XMLHttpRequest();
2232
2468
 
2233
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
2469
+ request.open(_config.method.toUpperCase(), _config.url, true);
2234
2470
 
2235
2471
  // Set the request timeout in MS
2236
- request.timeout = config.timeout;
2472
+ request.timeout = _config.timeout;
2237
2473
 
2238
2474
  function onloadend() {
2239
2475
  if (!request) {
@@ -2313,10 +2549,10 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2313
2549
 
2314
2550
  // Handle timeout
2315
2551
  request.ontimeout = function handleTimeout() {
2316
- let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2317
- const transitional = config.transitional || transitionalDefaults;
2318
- if (config.timeoutErrorMessage) {
2319
- timeoutErrorMessage = config.timeoutErrorMessage;
2552
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2553
+ const transitional = _config.transitional || transitionalDefaults;
2554
+ if (_config.timeoutErrorMessage) {
2555
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2320
2556
  }
2321
2557
  reject(new AxiosError$1(
2322
2558
  timeoutErrorMessage,
@@ -2328,22 +2564,6 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2328
2564
  request = null;
2329
2565
  };
2330
2566
 
2331
- // Add xsrf header
2332
- // This is only done if running in a standard browser environment.
2333
- // Specifically not if we're in a web worker, or react-native.
2334
- if(platform.hasStandardBrowserEnv) {
2335
- withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
2336
-
2337
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
2338
- // Add xsrf header
2339
- const xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2340
-
2341
- if (xsrfValue) {
2342
- requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2343
- }
2344
- }
2345
- }
2346
-
2347
2567
  // Remove Content-Type if data is undefined
2348
2568
  requestData === undefined && requestHeaders.setContentType(null);
2349
2569
 
@@ -2355,26 +2575,31 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2355
2575
  }
2356
2576
 
2357
2577
  // Add withCredentials to request if needed
2358
- if (!utils$1.isUndefined(config.withCredentials)) {
2359
- request.withCredentials = !!config.withCredentials;
2578
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2579
+ request.withCredentials = !!_config.withCredentials;
2360
2580
  }
2361
2581
 
2362
2582
  // Add responseType to request if needed
2363
2583
  if (responseType && responseType !== 'json') {
2364
- request.responseType = config.responseType;
2584
+ request.responseType = _config.responseType;
2365
2585
  }
2366
2586
 
2367
2587
  // Handle progress if needed
2368
- if (typeof config.onDownloadProgress === 'function') {
2369
- request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
2588
+ if (onDownloadProgress) {
2589
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2590
+ request.addEventListener('progress', downloadThrottled);
2370
2591
  }
2371
2592
 
2372
2593
  // Not all browsers support upload events
2373
- if (typeof config.onUploadProgress === 'function' && request.upload) {
2374
- request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
2594
+ if (onUploadProgress && request.upload) {
2595
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
2596
+
2597
+ request.upload.addEventListener('progress', uploadThrottled);
2598
+
2599
+ request.upload.addEventListener('loadend', flushUpload);
2375
2600
  }
2376
2601
 
2377
- if (config.cancelToken || config.signal) {
2602
+ if (_config.cancelToken || _config.signal) {
2378
2603
  // Handle cancellation
2379
2604
  // eslint-disable-next-line func-names
2380
2605
  onCanceled = cancel => {
@@ -2386,13 +2611,13 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2386
2611
  request = null;
2387
2612
  };
2388
2613
 
2389
- config.cancelToken && config.cancelToken.subscribe(onCanceled);
2390
- if (config.signal) {
2391
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2614
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2615
+ if (_config.signal) {
2616
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
2392
2617
  }
2393
2618
  }
2394
2619
 
2395
- const protocol = parseProtocol(fullPath);
2620
+ const protocol = parseProtocol(_config.url);
2396
2621
 
2397
2622
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
2398
2623
  reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
@@ -2405,9 +2630,339 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2405
2630
  });
2406
2631
  };
2407
2632
 
2633
+ const composeSignals = (signals, timeout) => {
2634
+ let controller = new AbortController();
2635
+
2636
+ let aborted;
2637
+
2638
+ const onabort = function (cancel) {
2639
+ if (!aborted) {
2640
+ aborted = true;
2641
+ unsubscribe();
2642
+ const err = cancel instanceof Error ? cancel : this.reason;
2643
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
2644
+ }
2645
+ };
2646
+
2647
+ let timer = timeout && setTimeout(() => {
2648
+ onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
2649
+ }, timeout);
2650
+
2651
+ const unsubscribe = () => {
2652
+ if (signals) {
2653
+ timer && clearTimeout(timer);
2654
+ timer = null;
2655
+ signals.forEach(signal => {
2656
+ signal &&
2657
+ (signal.removeEventListener ? signal.removeEventListener('abort', onabort) : signal.unsubscribe(onabort));
2658
+ });
2659
+ signals = null;
2660
+ }
2661
+ };
2662
+
2663
+ signals.forEach((signal) => signal && signal.addEventListener && signal.addEventListener('abort', onabort));
2664
+
2665
+ const {signal} = controller;
2666
+
2667
+ signal.unsubscribe = unsubscribe;
2668
+
2669
+ return [signal, () => {
2670
+ timer && clearTimeout(timer);
2671
+ timer = null;
2672
+ }];
2673
+ };
2674
+
2675
+ const composeSignals$1 = composeSignals;
2676
+
2677
+ const streamChunk = function* (chunk, chunkSize) {
2678
+ let len = chunk.byteLength;
2679
+
2680
+ if (!chunkSize || len < chunkSize) {
2681
+ yield chunk;
2682
+ return;
2683
+ }
2684
+
2685
+ let pos = 0;
2686
+ let end;
2687
+
2688
+ while (pos < len) {
2689
+ end = pos + chunkSize;
2690
+ yield chunk.slice(pos, end);
2691
+ pos = end;
2692
+ }
2693
+ };
2694
+
2695
+ const readBytes = async function* (iterable, chunkSize, encode) {
2696
+ for await (const chunk of iterable) {
2697
+ yield* streamChunk(ArrayBuffer.isView(chunk) ? chunk : (await encode(String(chunk))), chunkSize);
2698
+ }
2699
+ };
2700
+
2701
+ const trackStream = (stream, chunkSize, onProgress, onFinish, encode) => {
2702
+ const iterator = readBytes(stream, chunkSize, encode);
2703
+
2704
+ let bytes = 0;
2705
+ let done;
2706
+ let _onFinish = (e) => {
2707
+ if (!done) {
2708
+ done = true;
2709
+ onFinish && onFinish(e);
2710
+ }
2711
+ };
2712
+
2713
+ return new ReadableStream({
2714
+ async pull(controller) {
2715
+ try {
2716
+ const {done, value} = await iterator.next();
2717
+
2718
+ if (done) {
2719
+ _onFinish();
2720
+ controller.close();
2721
+ return;
2722
+ }
2723
+
2724
+ let len = value.byteLength;
2725
+ if (onProgress) {
2726
+ let loadedBytes = bytes += len;
2727
+ onProgress(loadedBytes);
2728
+ }
2729
+ controller.enqueue(new Uint8Array(value));
2730
+ } catch (err) {
2731
+ _onFinish(err);
2732
+ throw err;
2733
+ }
2734
+ },
2735
+ cancel(reason) {
2736
+ _onFinish(reason);
2737
+ return iterator.return();
2738
+ }
2739
+ }, {
2740
+ highWaterMark: 2
2741
+ })
2742
+ };
2743
+
2744
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
2745
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
2746
+
2747
+ // used only inside the fetch adapter
2748
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2749
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2750
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2751
+ );
2752
+
2753
+ const test = (fn, ...args) => {
2754
+ try {
2755
+ return !!fn(...args);
2756
+ } catch (e) {
2757
+ return false
2758
+ }
2759
+ };
2760
+
2761
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
2762
+ let duplexAccessed = false;
2763
+
2764
+ const hasContentType = new Request(platform.origin, {
2765
+ body: new ReadableStream(),
2766
+ method: 'POST',
2767
+ get duplex() {
2768
+ duplexAccessed = true;
2769
+ return 'half';
2770
+ },
2771
+ }).headers.has('Content-Type');
2772
+
2773
+ return duplexAccessed && !hasContentType;
2774
+ });
2775
+
2776
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2777
+
2778
+ const supportsResponseStream = isReadableStreamSupported &&
2779
+ test(() => utils$1.isReadableStream(new Response('').body));
2780
+
2781
+
2782
+ const resolvers = {
2783
+ stream: supportsResponseStream && ((res) => res.body)
2784
+ };
2785
+
2786
+ isFetchSupported && (((res) => {
2787
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2788
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
2789
+ (_, config) => {
2790
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
2791
+ });
2792
+ });
2793
+ })(new Response));
2794
+
2795
+ const getBodyLength = async (body) => {
2796
+ if (body == null) {
2797
+ return 0;
2798
+ }
2799
+
2800
+ if(utils$1.isBlob(body)) {
2801
+ return body.size;
2802
+ }
2803
+
2804
+ if(utils$1.isSpecCompliantForm(body)) {
2805
+ return (await new Request(body).arrayBuffer()).byteLength;
2806
+ }
2807
+
2808
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2809
+ return body.byteLength;
2810
+ }
2811
+
2812
+ if(utils$1.isURLSearchParams(body)) {
2813
+ body = body + '';
2814
+ }
2815
+
2816
+ if(utils$1.isString(body)) {
2817
+ return (await encodeText(body)).byteLength;
2818
+ }
2819
+ };
2820
+
2821
+ const resolveBodyLength = async (headers, body) => {
2822
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
2823
+
2824
+ return length == null ? getBodyLength(body) : length;
2825
+ };
2826
+
2827
+ const fetchAdapter = isFetchSupported && (async (config) => {
2828
+ let {
2829
+ url,
2830
+ method,
2831
+ data,
2832
+ signal,
2833
+ cancelToken,
2834
+ timeout,
2835
+ onDownloadProgress,
2836
+ onUploadProgress,
2837
+ responseType,
2838
+ headers,
2839
+ withCredentials = 'same-origin',
2840
+ fetchOptions
2841
+ } = resolveConfig(config);
2842
+
2843
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2844
+
2845
+ let [composedSignal, stopTimeout] = (signal || cancelToken || timeout) ?
2846
+ composeSignals$1([signal, cancelToken], timeout) : [];
2847
+
2848
+ let finished, request;
2849
+
2850
+ const onFinish = () => {
2851
+ !finished && setTimeout(() => {
2852
+ composedSignal && composedSignal.unsubscribe();
2853
+ });
2854
+
2855
+ finished = true;
2856
+ };
2857
+
2858
+ let requestContentLength;
2859
+
2860
+ try {
2861
+ if (
2862
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2863
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2864
+ ) {
2865
+ let _request = new Request(url, {
2866
+ method: 'POST',
2867
+ body: data,
2868
+ duplex: "half"
2869
+ });
2870
+
2871
+ let contentTypeHeader;
2872
+
2873
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2874
+ headers.setContentType(contentTypeHeader);
2875
+ }
2876
+
2877
+ if (_request.body) {
2878
+ const [onProgress, flush] = progressEventDecorator(
2879
+ requestContentLength,
2880
+ progressEventReducer(asyncDecorator(onUploadProgress))
2881
+ );
2882
+
2883
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush, encodeText);
2884
+ }
2885
+ }
2886
+
2887
+ if (!utils$1.isString(withCredentials)) {
2888
+ withCredentials = withCredentials ? 'include' : 'omit';
2889
+ }
2890
+
2891
+ request = new Request(url, {
2892
+ ...fetchOptions,
2893
+ signal: composedSignal,
2894
+ method: method.toUpperCase(),
2895
+ headers: headers.normalize().toJSON(),
2896
+ body: data,
2897
+ duplex: "half",
2898
+ credentials: withCredentials
2899
+ });
2900
+
2901
+ let response = await fetch(request);
2902
+
2903
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
2904
+
2905
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
2906
+ const options = {};
2907
+
2908
+ ['status', 'statusText', 'headers'].forEach(prop => {
2909
+ options[prop] = response[prop];
2910
+ });
2911
+
2912
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
2913
+
2914
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2915
+ responseContentLength,
2916
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
2917
+ ) || [];
2918
+
2919
+ response = new Response(
2920
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2921
+ flush && flush();
2922
+ isStreamResponse && onFinish();
2923
+ }, encodeText),
2924
+ options
2925
+ );
2926
+ }
2927
+
2928
+ responseType = responseType || 'text';
2929
+
2930
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
2931
+
2932
+ !isStreamResponse && onFinish();
2933
+
2934
+ stopTimeout && stopTimeout();
2935
+
2936
+ return await new Promise((resolve, reject) => {
2937
+ settle(resolve, reject, {
2938
+ data: responseData,
2939
+ headers: AxiosHeaders$2.from(response.headers),
2940
+ status: response.status,
2941
+ statusText: response.statusText,
2942
+ config,
2943
+ request
2944
+ });
2945
+ })
2946
+ } catch (err) {
2947
+ onFinish();
2948
+
2949
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
2950
+ throw Object.assign(
2951
+ new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
2952
+ {
2953
+ cause: err.cause || err
2954
+ }
2955
+ )
2956
+ }
2957
+
2958
+ throw AxiosError$1.from(err, err && err.code, config, request);
2959
+ }
2960
+ });
2961
+
2408
2962
  const knownAdapters = {
2409
2963
  http: httpAdapter,
2410
- xhr: xhrAdapter
2964
+ xhr: xhrAdapter,
2965
+ fetch: fetchAdapter
2411
2966
  };
2412
2967
 
2413
2968
  utils$1.forEach(knownAdapters, (fn, value) => {
@@ -2551,109 +3106,7 @@ function dispatchRequest(config) {
2551
3106
  });
2552
3107
  }
2553
3108
 
2554
- const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSON() : thing;
2555
-
2556
- /**
2557
- * Config-specific merge-function which creates a new config-object
2558
- * by merging two configuration objects together.
2559
- *
2560
- * @param {Object} config1
2561
- * @param {Object} config2
2562
- *
2563
- * @returns {Object} New object resulting from merging config2 to config1
2564
- */
2565
- function mergeConfig$1(config1, config2) {
2566
- // eslint-disable-next-line no-param-reassign
2567
- config2 = config2 || {};
2568
- const config = {};
2569
-
2570
- function getMergedValue(target, source, caseless) {
2571
- if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2572
- return utils$1.merge.call({caseless}, target, source);
2573
- } else if (utils$1.isPlainObject(source)) {
2574
- return utils$1.merge({}, source);
2575
- } else if (utils$1.isArray(source)) {
2576
- return source.slice();
2577
- }
2578
- return source;
2579
- }
2580
-
2581
- // eslint-disable-next-line consistent-return
2582
- function mergeDeepProperties(a, b, caseless) {
2583
- if (!utils$1.isUndefined(b)) {
2584
- return getMergedValue(a, b, caseless);
2585
- } else if (!utils$1.isUndefined(a)) {
2586
- return getMergedValue(undefined, a, caseless);
2587
- }
2588
- }
2589
-
2590
- // eslint-disable-next-line consistent-return
2591
- function valueFromConfig2(a, b) {
2592
- if (!utils$1.isUndefined(b)) {
2593
- return getMergedValue(undefined, b);
2594
- }
2595
- }
2596
-
2597
- // eslint-disable-next-line consistent-return
2598
- function defaultToConfig2(a, b) {
2599
- if (!utils$1.isUndefined(b)) {
2600
- return getMergedValue(undefined, b);
2601
- } else if (!utils$1.isUndefined(a)) {
2602
- return getMergedValue(undefined, a);
2603
- }
2604
- }
2605
-
2606
- // eslint-disable-next-line consistent-return
2607
- function mergeDirectKeys(a, b, prop) {
2608
- if (prop in config2) {
2609
- return getMergedValue(a, b);
2610
- } else if (prop in config1) {
2611
- return getMergedValue(undefined, a);
2612
- }
2613
- }
2614
-
2615
- const mergeMap = {
2616
- url: valueFromConfig2,
2617
- method: valueFromConfig2,
2618
- data: valueFromConfig2,
2619
- baseURL: defaultToConfig2,
2620
- transformRequest: defaultToConfig2,
2621
- transformResponse: defaultToConfig2,
2622
- paramsSerializer: defaultToConfig2,
2623
- timeout: defaultToConfig2,
2624
- timeoutMessage: defaultToConfig2,
2625
- withCredentials: defaultToConfig2,
2626
- withXSRFToken: defaultToConfig2,
2627
- adapter: defaultToConfig2,
2628
- responseType: defaultToConfig2,
2629
- xsrfCookieName: defaultToConfig2,
2630
- xsrfHeaderName: defaultToConfig2,
2631
- onUploadProgress: defaultToConfig2,
2632
- onDownloadProgress: defaultToConfig2,
2633
- decompress: defaultToConfig2,
2634
- maxContentLength: defaultToConfig2,
2635
- maxBodyLength: defaultToConfig2,
2636
- beforeRedirect: defaultToConfig2,
2637
- transport: defaultToConfig2,
2638
- httpAgent: defaultToConfig2,
2639
- httpsAgent: defaultToConfig2,
2640
- cancelToken: defaultToConfig2,
2641
- socketPath: defaultToConfig2,
2642
- responseEncoding: defaultToConfig2,
2643
- validateStatus: mergeDirectKeys,
2644
- headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2645
- };
2646
-
2647
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2648
- const merge = mergeMap[prop] || mergeDeepProperties;
2649
- const configValue = merge(config1[prop], config2[prop], prop);
2650
- (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2651
- });
2652
-
2653
- return config;
2654
- }
2655
-
2656
- const VERSION$1 = "1.6.7";
3109
+ const VERSION$1 = "1.7.3";
2657
3110
 
2658
3111
  const validators$1 = {};
2659
3112
 
@@ -2779,12 +3232,15 @@ class Axios$1 {
2779
3232
 
2780
3233
  // slice off the Error: ... line
2781
3234
  const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
2782
-
2783
- if (!err.stack) {
2784
- err.stack = stack;
2785
- // match without the 2 top stack lines
2786
- } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
2787
- err.stack += '\n' + stack;
3235
+ try {
3236
+ if (!err.stack) {
3237
+ err.stack = stack;
3238
+ // match without the 2 top stack lines
3239
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3240
+ err.stack += '\n' + stack;
3241
+ }
3242
+ } catch (e) {
3243
+ // ignore the case where "stack" is an un-writable property
2788
3244
  }
2789
3245
  }
2790
3246