axios 1.2.0 → 1.2.1

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.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
1
+ // Axios v1.2.1 Copyright (c) 2022 Matt Zabriskie and contributors
2
2
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -1217,6 +1217,24 @@ const isStandardBrowserEnv = (() => {
1217
1217
  return typeof window !== 'undefined' && typeof document !== 'undefined';
1218
1218
  })();
1219
1219
 
1220
+ /**
1221
+ * Determine if we're running in a standard browser webWorker environment
1222
+ *
1223
+ * Although the `isStandardBrowserEnv` method indicates that
1224
+ * `allows axios to run in a web worker`, the WebWorker will still be
1225
+ * filtered out due to its judgment standard
1226
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1227
+ * This leads to a problem when axios post `FormData` in webWorker
1228
+ */
1229
+ const isStandardBrowserWebWorkerEnv = (() => {
1230
+ return (
1231
+ typeof WorkerGlobalScope !== 'undefined' &&
1232
+ self instanceof WorkerGlobalScope &&
1233
+ typeof self.importScripts === 'function'
1234
+ );
1235
+ })();
1236
+
1237
+
1220
1238
  const platform = {
1221
1239
  isBrowser: true,
1222
1240
  classes: {
@@ -1225,6 +1243,7 @@ const platform = {
1225
1243
  Blob
1226
1244
  },
1227
1245
  isStandardBrowserEnv,
1246
+ isStandardBrowserWebWorkerEnv,
1228
1247
  protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1229
1248
  };
1230
1249
 
@@ -2089,7 +2108,7 @@ function speedometer(samplesCount, min) {
2089
2108
 
2090
2109
  const passed = startedAt && now - startedAt;
2091
2110
 
2092
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2111
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2093
2112
  };
2094
2113
  }
2095
2114
 
@@ -2140,7 +2159,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2140
2159
  }
2141
2160
  }
2142
2161
 
2143
- if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
2162
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2144
2163
  requestHeaders.setContentType(false); // Let the browser set it
2145
2164
  }
2146
2165
 
@@ -2168,7 +2187,7 @@ const xhrAdapter = isXHRAdapterSupported && function (config) {
2168
2187
  const responseHeaders = AxiosHeaders$2.from(
2169
2188
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2170
2189
  );
2171
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2190
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2172
2191
  request.responseText : request.response;
2173
2192
  const response = {
2174
2193
  data: responseData,
@@ -2395,7 +2414,7 @@ function throwIfCancellationRequested(config) {
2395
2414
  }
2396
2415
 
2397
2416
  if (config.signal && config.signal.aborted) {
2398
- throw new CanceledError$1();
2417
+ throw new CanceledError$1(null, config);
2399
2418
  }
2400
2419
  }
2401
2420
 
@@ -2466,7 +2485,7 @@ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSO
2466
2485
  *
2467
2486
  * @returns {Object} New object resulting from merging config2 to config1
2468
2487
  */
2469
- function mergeConfig(config1, config2) {
2488
+ function mergeConfig$1(config1, config2) {
2470
2489
  // eslint-disable-next-line no-param-reassign
2471
2490
  config2 = config2 || {};
2472
2491
  const config = {};
@@ -2556,7 +2575,7 @@ function mergeConfig(config1, config2) {
2556
2575
  return config;
2557
2576
  }
2558
2577
 
2559
- const VERSION$1 = "1.2.0";
2578
+ const VERSION$1 = "1.2.1";
2560
2579
 
2561
2580
  const validators$1 = {};
2562
2581
 
@@ -2681,7 +2700,7 @@ class Axios$1 {
2681
2700
  config = configOrUrl || {};
2682
2701
  }
2683
2702
 
2684
- config = mergeConfig(this.defaults, config);
2703
+ config = mergeConfig$1(this.defaults, config);
2685
2704
 
2686
2705
  const {transitional, paramsSerializer, headers} = config;
2687
2706
 
@@ -2791,7 +2810,7 @@ class Axios$1 {
2791
2810
  }
2792
2811
 
2793
2812
  getUri(config) {
2794
- config = mergeConfig(this.defaults, config);
2813
+ config = mergeConfig$1(this.defaults, config);
2795
2814
  const fullPath = buildFullPath(config.baseURL, config.url);
2796
2815
  return buildURL(fullPath, config.params, config.paramsSerializer);
2797
2816
  }
@@ -2801,7 +2820,7 @@ class Axios$1 {
2801
2820
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2802
2821
  /*eslint func-names:0*/
2803
2822
  Axios$1.prototype[method] = function(url, config) {
2804
- return this.request(mergeConfig(config || {}, {
2823
+ return this.request(mergeConfig$1(config || {}, {
2805
2824
  method,
2806
2825
  url,
2807
2826
  data: (config || {}).data
@@ -2814,7 +2833,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2814
2833
 
2815
2834
  function generateHTTPMethod(isForm) {
2816
2835
  return function httpMethod(url, data, config) {
2817
- return this.request(mergeConfig(config || {}, {
2836
+ return this.request(mergeConfig$1(config || {}, {
2818
2837
  method,
2819
2838
  headers: isForm ? {
2820
2839
  'Content-Type': 'multipart/form-data'
@@ -3007,7 +3026,7 @@ function createInstance(defaultConfig) {
3007
3026
 
3008
3027
  // Factory for creating new instances
3009
3028
  instance.create = function create(instanceConfig) {
3010
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
3029
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
3011
3030
  };
3012
3031
 
3013
3032
  return instance;
@@ -3042,6 +3061,9 @@ axios.spread = spread$1;
3042
3061
  // Expose isAxiosError
3043
3062
  axios.isAxiosError = isAxiosError$1;
3044
3063
 
3064
+ // Expose mergeConfig
3065
+ axios.mergeConfig = mergeConfig$1;
3066
+
3045
3067
  axios.AxiosHeaders = AxiosHeaders$2;
3046
3068
 
3047
3069
  axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
@@ -3067,8 +3089,9 @@ const {
3067
3089
  spread,
3068
3090
  toFormData,
3069
3091
  AxiosHeaders,
3070
- formToJSON
3092
+ formToJSON,
3093
+ mergeConfig
3071
3094
  } = axios$1;
3072
3095
 
3073
- export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, spread, toFormData };
3096
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
3074
3097
  //# sourceMappingURL=axios.js.map