mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
chore(release): v1.3.0 (#5513)
Co-authored-by: DigitalBrainJS <DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9263473154
commit
7fbfbbeff6
@@ -1,5 +1,23 @@
|
||||
# Changelog
|
||||
|
||||
# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **headers:** fixed & optimized clear method; ([#5507](https://github.com/axios/axios/issues/5507)) ([9915635](https://github.com/axios/axios/commit/9915635c69d0ab70daca5738488421f67ca60959))
|
||||
* **http:** add zlib headers if missing ([#5497](https://github.com/axios/axios/issues/5497)) ([65e8d1e](https://github.com/axios/axios/commit/65e8d1e28ce829f47a837e45129730e541950d3c))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **fomdata:** added support for spec-compliant FormData & Blob types; ([#5316](https://github.com/axios/axios/issues/5316)) ([6ac574e](https://github.com/axios/axios/commit/6ac574e00a06731288347acea1e8246091196953))
|
||||
|
||||
### Contributors to this release
|
||||
|
||||
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )")
|
||||
- <img src="https://avatars.githubusercontent.com/u/35015993?v=4&s=18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )")
|
||||
|
||||
## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"main": "./dist/axios.js",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"homepage": "https://axios-http.com",
|
||||
"authors": [
|
||||
"Matt Zabriskie"
|
||||
|
||||
Vendored
+50
-24
@@ -1,4 +1,4 @@
|
||||
// Axios v1.2.6 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
// Axios v1.3.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
@@ -598,7 +598,7 @@
|
||||
/* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
|
||||
var isHTMLForm = kindOfTest('HTMLFormElement');
|
||||
var toCamelCase = function toCamelCase(str) {
|
||||
return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
||||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
});
|
||||
};
|
||||
@@ -670,6 +670,34 @@
|
||||
value = +value;
|
||||
return Number.isFinite(value) ? value : defaultValue;
|
||||
};
|
||||
var ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
||||
var DIGIT = '0123456789';
|
||||
var ALPHABET = {
|
||||
DIGIT: DIGIT,
|
||||
ALPHA: ALPHA,
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||||
};
|
||||
var generateString = function generateString() {
|
||||
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
|
||||
var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
|
||||
var str = '';
|
||||
var length = alphabet.length;
|
||||
while (size--) {
|
||||
str += alphabet[Math.random() * length | 0];
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliantForm(thing) {
|
||||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
||||
}
|
||||
var toJSONObject = function toJSONObject(obj) {
|
||||
var stack = new Array(10);
|
||||
var visit = function visit(source, i) {
|
||||
@@ -739,6 +767,9 @@
|
||||
findKey: findKey,
|
||||
global: _global,
|
||||
isContextDefined: isContextDefined,
|
||||
ALPHABET: ALPHABET,
|
||||
generateString: generateString,
|
||||
isSpecCompliantForm: isSpecCompliantForm,
|
||||
toJSONObject: toJSONObject
|
||||
};
|
||||
|
||||
@@ -817,9 +848,8 @@
|
||||
return axiosError;
|
||||
};
|
||||
|
||||
/* eslint-env browser */
|
||||
var browser = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' ? self.FormData : window.FormData;
|
||||
var FormData$2 = browser;
|
||||
// eslint-disable-next-line strict
|
||||
var httpAdapter = null;
|
||||
|
||||
/**
|
||||
* Determines if the given thing is a array or js object.
|
||||
@@ -875,17 +905,6 @@
|
||||
return /^is[A-Z]/.test(prop);
|
||||
});
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliant(thing) {
|
||||
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data object to FormData
|
||||
*
|
||||
@@ -915,7 +934,7 @@
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
formData = formData || new (FormData$2 || FormData)();
|
||||
formData = formData || new (FormData)();
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = utils.toFlatObject(options, {
|
||||
@@ -932,7 +951,7 @@
|
||||
var dots = options.dots;
|
||||
var indexes = options.indexes;
|
||||
var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
var useBlob = _Blob && isSpecCompliant(formData);
|
||||
var useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
if (!utils.isFunction(visitor)) {
|
||||
throw new TypeError('visitor must be a function');
|
||||
}
|
||||
@@ -1638,8 +1657,18 @@
|
||||
}
|
||||
}, {
|
||||
key: "clear",
|
||||
value: function clear() {
|
||||
return Object.keys(this).forEach(this["delete"].bind(this));
|
||||
value: function clear(matcher) {
|
||||
var keys = Object.keys(this);
|
||||
var i = keys.length;
|
||||
var deleted = false;
|
||||
while (i--) {
|
||||
var key = keys[i];
|
||||
if (!matcher || matchHeaderValue(this, this[key], key, matcher)) {
|
||||
delete this[key];
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
}, {
|
||||
key: "normalize",
|
||||
@@ -1785,9 +1814,6 @@
|
||||
__CANCEL__: true
|
||||
});
|
||||
|
||||
// eslint-disable-next-line strict
|
||||
var httpAdapter = null;
|
||||
|
||||
/**
|
||||
* Resolve or reject a Promise based on response status.
|
||||
*
|
||||
@@ -2397,7 +2423,7 @@
|
||||
return config;
|
||||
}
|
||||
|
||||
var VERSION = "1.2.6";
|
||||
var VERSION = "1.3.0";
|
||||
|
||||
var validators$1 = {};
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+55
-25
@@ -1,4 +1,4 @@
|
||||
// Axios v1.2.6 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
// Axios v1.3.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
'use strict';
|
||||
|
||||
function bind(fn, thisArg) {
|
||||
@@ -517,7 +517,7 @@ const matchAll = (regExp, str) => {
|
||||
const isHTMLForm = kindOfTest('HTMLFormElement');
|
||||
|
||||
const toCamelCase = str => {
|
||||
return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,
|
||||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
||||
function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
}
|
||||
@@ -601,6 +601,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
||||
return Number.isFinite(value) ? value : defaultValue;
|
||||
};
|
||||
|
||||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
const DIGIT = '0123456789';
|
||||
|
||||
const ALPHABET = {
|
||||
DIGIT,
|
||||
ALPHA,
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||||
};
|
||||
|
||||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||||
let str = '';
|
||||
const {length} = alphabet;
|
||||
while (size--) {
|
||||
str += alphabet[Math.random() * length|0];
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliantForm(thing) {
|
||||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
||||
}
|
||||
|
||||
const toJSONObject = (obj) => {
|
||||
const stack = new Array(10);
|
||||
|
||||
@@ -678,6 +709,9 @@ var utils = {
|
||||
findKey,
|
||||
global: _global,
|
||||
isContextDefined,
|
||||
ALPHABET,
|
||||
generateString,
|
||||
isSpecCompliantForm,
|
||||
toJSONObject
|
||||
};
|
||||
|
||||
@@ -776,10 +810,8 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
||||
return axiosError;
|
||||
};
|
||||
|
||||
/* eslint-env browser */
|
||||
var browser = typeof self == 'object' ? self.FormData : window.FormData;
|
||||
|
||||
var FormData$2 = browser;
|
||||
// eslint-disable-next-line strict
|
||||
var httpAdapter = null;
|
||||
|
||||
/**
|
||||
* Determines if the given thing is a array or js object.
|
||||
@@ -836,17 +868,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
||||
return /^is[A-Z]/.test(prop);
|
||||
});
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliant(thing) {
|
||||
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data object to FormData
|
||||
*
|
||||
@@ -876,7 +897,7 @@ function toFormData(obj, formData, options) {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
formData = formData || new (FormData$2 || FormData)();
|
||||
formData = formData || new (FormData)();
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = utils.toFlatObject(options, {
|
||||
@@ -894,7 +915,7 @@ function toFormData(obj, formData, options) {
|
||||
const dots = options.dots;
|
||||
const indexes = options.indexes;
|
||||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
const useBlob = _Blob && isSpecCompliant(formData);
|
||||
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
|
||||
if (!utils.isFunction(visitor)) {
|
||||
throw new TypeError('visitor must be a function');
|
||||
@@ -1734,8 +1755,20 @@ class AxiosHeaders {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
clear() {
|
||||
return Object.keys(this).forEach(this.delete.bind(this));
|
||||
clear(matcher) {
|
||||
const keys = Object.keys(this);
|
||||
let i = keys.length;
|
||||
let deleted = false;
|
||||
|
||||
while (i--) {
|
||||
const key = keys[i];
|
||||
if(!matcher || matchHeaderValue(this, this[key], key, matcher)) {
|
||||
delete this[key];
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
normalize(format) {
|
||||
@@ -1879,9 +1912,6 @@ utils.inherits(CanceledError, AxiosError, {
|
||||
__CANCEL__: true
|
||||
});
|
||||
|
||||
// eslint-disable-next-line strict
|
||||
var httpAdapter = null;
|
||||
|
||||
/**
|
||||
* Resolve or reject a Promise based on response status.
|
||||
*
|
||||
@@ -2582,7 +2612,7 @@ function mergeConfig(config1, config2) {
|
||||
return config;
|
||||
}
|
||||
|
||||
const VERSION = "1.2.6";
|
||||
const VERSION = "1.3.0";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+55
-25
@@ -1,4 +1,4 @@
|
||||
// Axios v1.2.6 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
// Axios v1.3.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
function bind(fn, thisArg) {
|
||||
return function wrap() {
|
||||
return fn.apply(thisArg, arguments);
|
||||
@@ -515,7 +515,7 @@ const matchAll = (regExp, str) => {
|
||||
const isHTMLForm = kindOfTest('HTMLFormElement');
|
||||
|
||||
const toCamelCase = str => {
|
||||
return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,
|
||||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
||||
function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
}
|
||||
@@ -599,6 +599,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
||||
return Number.isFinite(value) ? value : defaultValue;
|
||||
};
|
||||
|
||||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
const DIGIT = '0123456789';
|
||||
|
||||
const ALPHABET = {
|
||||
DIGIT,
|
||||
ALPHA,
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||||
};
|
||||
|
||||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||||
let str = '';
|
||||
const {length} = alphabet;
|
||||
while (size--) {
|
||||
str += alphabet[Math.random() * length|0];
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliantForm(thing) {
|
||||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
||||
}
|
||||
|
||||
const toJSONObject = (obj) => {
|
||||
const stack = new Array(10);
|
||||
|
||||
@@ -676,6 +707,9 @@ const utils = {
|
||||
findKey,
|
||||
global: _global,
|
||||
isContextDefined,
|
||||
ALPHABET,
|
||||
generateString,
|
||||
isSpecCompliantForm,
|
||||
toJSONObject
|
||||
};
|
||||
|
||||
@@ -774,10 +808,8 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
||||
return axiosError;
|
||||
};
|
||||
|
||||
/* eslint-env browser */
|
||||
var browser = typeof self == 'object' ? self.FormData : window.FormData;
|
||||
|
||||
const FormData$2 = browser;
|
||||
// eslint-disable-next-line strict
|
||||
const httpAdapter = null;
|
||||
|
||||
/**
|
||||
* Determines if the given thing is a array or js object.
|
||||
@@ -834,17 +866,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
||||
return /^is[A-Z]/.test(prop);
|
||||
});
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliant(thing) {
|
||||
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data object to FormData
|
||||
*
|
||||
@@ -874,7 +895,7 @@ function toFormData$1(obj, formData, options) {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
formData = formData || new (FormData$2 || FormData)();
|
||||
formData = formData || new (FormData)();
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = utils.toFlatObject(options, {
|
||||
@@ -892,7 +913,7 @@ function toFormData$1(obj, formData, options) {
|
||||
const dots = options.dots;
|
||||
const indexes = options.indexes;
|
||||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
const useBlob = _Blob && isSpecCompliant(formData);
|
||||
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
|
||||
if (!utils.isFunction(visitor)) {
|
||||
throw new TypeError('visitor must be a function');
|
||||
@@ -1732,8 +1753,20 @@ class AxiosHeaders$1 {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
clear() {
|
||||
return Object.keys(this).forEach(this.delete.bind(this));
|
||||
clear(matcher) {
|
||||
const keys = Object.keys(this);
|
||||
let i = keys.length;
|
||||
let deleted = false;
|
||||
|
||||
while (i--) {
|
||||
const key = keys[i];
|
||||
if(!matcher || matchHeaderValue(this, this[key], key, matcher)) {
|
||||
delete this[key];
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
normalize(format) {
|
||||
@@ -1877,9 +1910,6 @@ utils.inherits(CanceledError$1, AxiosError$1, {
|
||||
__CANCEL__: true
|
||||
});
|
||||
|
||||
// eslint-disable-next-line strict
|
||||
const httpAdapter = null;
|
||||
|
||||
/**
|
||||
* Resolve or reject a Promise based on response status.
|
||||
*
|
||||
@@ -2580,7 +2610,7 @@ function mergeConfig$1(config1, config2) {
|
||||
return config;
|
||||
}
|
||||
|
||||
const VERSION$1 = "1.2.6";
|
||||
const VERSION$1 = "1.3.0";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+229
-20
@@ -1,4 +1,4 @@
|
||||
// Axios v1.2.6 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
// Axios v1.3.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
'use strict';
|
||||
|
||||
const FormData$1 = require('form-data');
|
||||
@@ -538,7 +538,7 @@ const matchAll = (regExp, str) => {
|
||||
const isHTMLForm = kindOfTest('HTMLFormElement');
|
||||
|
||||
const toCamelCase = str => {
|
||||
return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,
|
||||
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
||||
function replacer(m, p1, p2) {
|
||||
return p1.toUpperCase() + p2;
|
||||
}
|
||||
@@ -622,6 +622,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
||||
return Number.isFinite(value) ? value : defaultValue;
|
||||
};
|
||||
|
||||
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
const DIGIT = '0123456789';
|
||||
|
||||
const ALPHABET = {
|
||||
DIGIT,
|
||||
ALPHA,
|
||||
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
||||
};
|
||||
|
||||
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
||||
let str = '';
|
||||
const {length} = alphabet;
|
||||
while (size--) {
|
||||
str += alphabet[Math.random() * length|0];
|
||||
}
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliantForm(thing) {
|
||||
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
||||
}
|
||||
|
||||
const toJSONObject = (obj) => {
|
||||
const stack = new Array(10);
|
||||
|
||||
@@ -699,6 +730,9 @@ const utils = {
|
||||
findKey,
|
||||
global: _global,
|
||||
isContextDefined,
|
||||
ALPHABET,
|
||||
generateString,
|
||||
isSpecCompliantForm,
|
||||
toJSONObject
|
||||
};
|
||||
|
||||
@@ -852,17 +886,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
||||
return /^is[A-Z]/.test(prop);
|
||||
});
|
||||
|
||||
/**
|
||||
* If the thing is a FormData object, return true, otherwise return false.
|
||||
*
|
||||
* @param {unknown} thing - The thing to check.
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isSpecCompliant(thing) {
|
||||
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data object to FormData
|
||||
*
|
||||
@@ -910,7 +933,7 @@ function toFormData(obj, formData, options) {
|
||||
const dots = options.dots;
|
||||
const indexes = options.indexes;
|
||||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
const useBlob = _Blob && isSpecCompliant(formData);
|
||||
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
|
||||
if (!utils.isFunction(visitor)) {
|
||||
throw new TypeError('visitor must be a function');
|
||||
@@ -1697,8 +1720,20 @@ class AxiosHeaders {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
clear() {
|
||||
return Object.keys(this).forEach(this.delete.bind(this));
|
||||
clear(matcher) {
|
||||
const keys = Object.keys(this);
|
||||
let i = keys.length;
|
||||
let deleted = false;
|
||||
|
||||
while (i--) {
|
||||
const key = keys[i];
|
||||
if(!matcher || matchHeaderValue(this, this[key], key, matcher)) {
|
||||
delete this[key];
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
normalize(format) {
|
||||
@@ -1911,7 +1946,7 @@ function buildFullPath(baseURL, requestedURL) {
|
||||
return requestedURL;
|
||||
}
|
||||
|
||||
const VERSION = "1.2.6";
|
||||
const VERSION = "1.3.0";
|
||||
|
||||
function parseProtocol(url) {
|
||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||
@@ -2233,6 +2268,154 @@ class AxiosTransformStream extends stream__default["default"].Transform{
|
||||
|
||||
const AxiosTransformStream$1 = AxiosTransformStream;
|
||||
|
||||
const {asyncIterator} = Symbol;
|
||||
|
||||
const readBlob = async function* (blob) {
|
||||
if (blob.stream) {
|
||||
yield* blob.stream();
|
||||
} else if (blob.arrayBuffer) {
|
||||
yield await blob.arrayBuffer();
|
||||
} else if (blob[asyncIterator]) {
|
||||
yield* blob[asyncIterator]();
|
||||
} else {
|
||||
yield blob;
|
||||
}
|
||||
};
|
||||
|
||||
const readBlob$1 = readBlob;
|
||||
|
||||
const BOUNDARY_ALPHABET = utils.ALPHABET.ALPHA_DIGIT + '-_';
|
||||
|
||||
const textEncoder = new TextEncoder();
|
||||
|
||||
const CRLF = '\r\n';
|
||||
const CRLF_BYTES = textEncoder.encode(CRLF);
|
||||
const CRLF_BYTES_COUNT = 2;
|
||||
|
||||
class FormDataPart {
|
||||
constructor(name, value) {
|
||||
const {escapeName} = this.constructor;
|
||||
const isStringValue = utils.isString(value);
|
||||
|
||||
let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${
|
||||
!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''
|
||||
}${CRLF}`;
|
||||
|
||||
if (isStringValue) {
|
||||
value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
|
||||
} else {
|
||||
headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`;
|
||||
}
|
||||
|
||||
this.headers = textEncoder.encode(headers + CRLF);
|
||||
|
||||
this.contentLength = isStringValue ? value.byteLength : value.size;
|
||||
|
||||
this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
|
||||
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
async *encode(){
|
||||
yield this.headers;
|
||||
|
||||
const {value} = this;
|
||||
|
||||
if(utils.isTypedArray(value)) {
|
||||
yield value;
|
||||
} else {
|
||||
yield* readBlob$1(value);
|
||||
}
|
||||
|
||||
yield CRLF_BYTES;
|
||||
}
|
||||
|
||||
static escapeName(name) {
|
||||
return String(name).replace(/[\r\n"]/g, (match) => ({
|
||||
'\r' : '%0D',
|
||||
'\n' : '%0A',
|
||||
'"' : '%22',
|
||||
}[match]));
|
||||
}
|
||||
}
|
||||
|
||||
const formDataToStream = (form, headersHandler, options) => {
|
||||
const {
|
||||
tag = 'form-data-boundary',
|
||||
size = 25,
|
||||
boundary = tag + '-' + utils.generateString(size, BOUNDARY_ALPHABET)
|
||||
} = options || {};
|
||||
|
||||
if(!utils.isFormData(form)) {
|
||||
throw TypeError('FormData instance required');
|
||||
}
|
||||
|
||||
if (boundary.length < 1 || boundary.length > 70) {
|
||||
throw Error('boundary must be 10-70 characters long')
|
||||
}
|
||||
|
||||
const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
|
||||
const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
|
||||
let contentLength = footerBytes.byteLength;
|
||||
|
||||
const parts = Array.from(form.entries()).map(([name, value]) => {
|
||||
const part = new FormDataPart(name, value);
|
||||
contentLength += part.size;
|
||||
return part;
|
||||
});
|
||||
|
||||
contentLength += boundaryBytes.byteLength * parts.length;
|
||||
|
||||
contentLength = utils.toFiniteNumber(contentLength);
|
||||
|
||||
const computedHeaders = {
|
||||
'Content-Type': `multipart/form-data; boundary=${boundary}`
|
||||
};
|
||||
|
||||
if (Number.isFinite(contentLength)) {
|
||||
computedHeaders['Content-Length'] = contentLength;
|
||||
}
|
||||
|
||||
headersHandler && headersHandler(computedHeaders);
|
||||
|
||||
return stream.Readable.from((async function *() {
|
||||
for(const part of parts) {
|
||||
yield boundaryBytes;
|
||||
yield* part.encode();
|
||||
}
|
||||
|
||||
yield footerBytes;
|
||||
})());
|
||||
};
|
||||
|
||||
const formDataToStream$1 = formDataToStream;
|
||||
|
||||
class ZlibHeaderTransformStream extends stream__default["default"].Transform {
|
||||
__transform(chunk, encoding, callback) {
|
||||
this.push(chunk);
|
||||
callback();
|
||||
}
|
||||
|
||||
_transform(chunk, encoding, callback) {
|
||||
if (chunk.length !== 0) {
|
||||
this._transform = this.__transform;
|
||||
|
||||
// Add Default Compression headers if no zlib headers are present
|
||||
if (chunk[0] !== 120) { // Hex: 78
|
||||
const header = Buffer.alloc(2);
|
||||
header[0] = 120; // Hex: 78
|
||||
header[1] = 156; // Hex: 9C
|
||||
this.push(header, encoding);
|
||||
}
|
||||
}
|
||||
|
||||
this.__transform(chunk, encoding, callback);
|
||||
}
|
||||
}
|
||||
|
||||
const ZlibHeaderTransformStream$1 = ZlibHeaderTransformStream;
|
||||
|
||||
const zlibOptions = {
|
||||
flush: zlib__default["default"].constants.Z_SYNC_FLUSH,
|
||||
finishFlush: zlib__default["default"].constants.Z_SYNC_FLUSH
|
||||
@@ -2455,9 +2638,27 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
||||
let maxUploadRate = undefined;
|
||||
let maxDownloadRate = undefined;
|
||||
|
||||
// support for https://www.npmjs.com/package/form-data api
|
||||
if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
||||
// support for spec compliant FormData objects
|
||||
if (utils.isSpecCompliantForm(data)) {
|
||||
const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
|
||||
|
||||
data = formDataToStream$1(data, (formHeaders) => {
|
||||
headers.set(formHeaders);
|
||||
}, {
|
||||
tag: `axios-${VERSION}-boundary`,
|
||||
boundary: userBoundary && userBoundary[1] || undefined
|
||||
});
|
||||
// support for https://www.npmjs.com/package/form-data api
|
||||
} else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
||||
headers.set(data.getHeaders());
|
||||
if (utils.isFunction(data.getLengthSync)) { // check if the undocumented API exists
|
||||
const knownLength = data.getLengthSync();
|
||||
!utils.isUndefined(knownLength) && headers.setContentLength(knownLength, false);
|
||||
}
|
||||
} else if (utils.isBlob(data)) {
|
||||
data.size && headers.setContentType(data.type || 'application/octet-stream');
|
||||
headers.setContentLength(data.size || 0);
|
||||
data = stream__default["default"].Readable.from(readBlob$1(data));
|
||||
} else if (data && !utils.isStream(data)) {
|
||||
if (Buffer.isBuffer(data)) ; else if (utils.isArrayBuffer(data)) {
|
||||
data = Buffer.from(new Uint8Array(data));
|
||||
@@ -2472,7 +2673,7 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
||||
}
|
||||
|
||||
// Add Content-Length header if data exists
|
||||
headers.set('Content-Length', data.length, false);
|
||||
headers.setContentLength(data.length, false);
|
||||
|
||||
if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
|
||||
return reject(new AxiosError(
|
||||
@@ -2636,7 +2837,15 @@ const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
||||
case 'x-gzip':
|
||||
case 'compress':
|
||||
case 'x-compress':
|
||||
// add the unzipper to the body stream processing pipeline
|
||||
streams.push(zlib__default["default"].createUnzip(zlibOptions));
|
||||
|
||||
// remove the content-encoding in order to not confuse downstream operations
|
||||
delete res.headers['content-encoding'];
|
||||
break;
|
||||
case 'deflate':
|
||||
streams.push(new ZlibHeaderTransformStream$1());
|
||||
|
||||
// add the unzipper to the body stream processing pipeline
|
||||
streams.push(zlib__default["default"].createUnzip(zlibOptions));
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
export const VERSION = "1.2.6";
|
||||
export const VERSION = "1.3.0";
|
||||
Generated
+43
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "axios",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.0",
|
||||
@@ -35,6 +35,7 @@
|
||||
"es6-promise": "^4.2.8",
|
||||
"eslint": "^8.17.0",
|
||||
"express": "^4.18.1",
|
||||
"formdata-node": "^5.0.0",
|
||||
"formidable": "^2.0.1",
|
||||
"fs-extra": "^10.1.0",
|
||||
"get-stream": "^3.0.0",
|
||||
@@ -10748,6 +10749,28 @@
|
||||
"node": ">= 14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-node": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-5.0.0.tgz",
|
||||
"integrity": "sha512-zrGsVVS56jJo+htsVv7ffXuzie91a2NrU1cPamvtPaSyRX++SH+4KXlGoOt+ncgDJ4bFA2SAQ+QGA+p4l1vciw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"node-domexception": "1.0.0",
|
||||
"web-streams-polyfill": "4.0.0-beta.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-node/node_modules/web-streams-polyfill": {
|
||||
"version": "4.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
@@ -32465,6 +32488,24 @@
|
||||
"integrity": "sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==",
|
||||
"dev": true
|
||||
},
|
||||
"formdata-node": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-5.0.0.tgz",
|
||||
"integrity": "sha512-zrGsVVS56jJo+htsVv7ffXuzie91a2NrU1cPamvtPaSyRX++SH+4KXlGoOt+ncgDJ4bFA2SAQ+QGA+p4l1vciw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"node-domexception": "1.0.0",
|
||||
"web-streams-polyfill": "4.0.0-beta.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"web-streams-polyfill": {
|
||||
"version": "4.0.0-beta.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
|
||||
"integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"version": "1.2.6",
|
||||
"version": "1.3.0",
|
||||
"description": "Promise based HTTP client for the browser and node.js",
|
||||
"main": "index.js",
|
||||
"exports": {
|
||||
@@ -204,4 +204,4 @@
|
||||
"@commitlint/config-conventional"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user