mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
chore(release): v1.6.1 (#6060)
Co-authored-by: DigitalBrainJS <DigitalBrainJS@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
cb8bb2beb2
commit
a22f4b918a
Vendored
+141
-139
@@ -1,4 +1,4 @@
|
||||
// Axios v1.6.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
// Axios v1.6.1 Copyright (c) 2023 Matt Zabriskie and contributors
|
||||
'use strict';
|
||||
|
||||
function bind(fn, thisArg) {
|
||||
@@ -673,7 +673,7 @@ const isAsyncFn = kindOfTest('AsyncFunction');
|
||||
const isThenable = (thing) =>
|
||||
thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
||||
|
||||
var utils = {
|
||||
var utils$1 = {
|
||||
isArray,
|
||||
isArrayBuffer,
|
||||
isBuffer,
|
||||
@@ -755,7 +755,7 @@ function AxiosError(message, code, config, request, response) {
|
||||
response && (this.response = response);
|
||||
}
|
||||
|
||||
utils.inherits(AxiosError, Error, {
|
||||
utils$1.inherits(AxiosError, Error, {
|
||||
toJSON: function toJSON() {
|
||||
return {
|
||||
// Standard
|
||||
@@ -770,7 +770,7 @@ utils.inherits(AxiosError, Error, {
|
||||
columnNumber: this.columnNumber,
|
||||
stack: this.stack,
|
||||
// Axios
|
||||
config: utils.toJSONObject(this.config),
|
||||
config: utils$1.toJSONObject(this.config),
|
||||
code: this.code,
|
||||
status: this.response && this.response.status ? this.response.status : null
|
||||
};
|
||||
@@ -805,7 +805,7 @@ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
|
||||
AxiosError.from = (error, code, config, request, response, customProps) => {
|
||||
const axiosError = Object.create(prototype$1);
|
||||
|
||||
utils.toFlatObject(error, axiosError, function filter(obj) {
|
||||
utils$1.toFlatObject(error, axiosError, function filter(obj) {
|
||||
return obj !== Error.prototype;
|
||||
}, prop => {
|
||||
return prop !== 'isAxiosError';
|
||||
@@ -833,7 +833,7 @@ var httpAdapter = null;
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isVisitable(thing) {
|
||||
return utils.isPlainObject(thing) || utils.isArray(thing);
|
||||
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,7 +844,7 @@ function isVisitable(thing) {
|
||||
* @returns {string} the key without the brackets.
|
||||
*/
|
||||
function removeBrackets(key) {
|
||||
return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
||||
return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -873,10 +873,10 @@ function renderKey(path, key, dots) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isFlatArray(arr) {
|
||||
return utils.isArray(arr) && !arr.some(isVisitable);
|
||||
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
||||
}
|
||||
|
||||
const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
||||
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
||||
return /^is[A-Z]/.test(prop);
|
||||
});
|
||||
|
||||
@@ -904,7 +904,7 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
||||
* @returns
|
||||
*/
|
||||
function toFormData(obj, formData, options) {
|
||||
if (!utils.isObject(obj)) {
|
||||
if (!utils$1.isObject(obj)) {
|
||||
throw new TypeError('target must be an object');
|
||||
}
|
||||
|
||||
@@ -912,13 +912,13 @@ function toFormData(obj, formData, options) {
|
||||
formData = formData || new (FormData)();
|
||||
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
options = utils.toFlatObject(options, {
|
||||
options = utils$1.toFlatObject(options, {
|
||||
metaTokens: true,
|
||||
dots: false,
|
||||
indexes: false
|
||||
}, false, function defined(option, source) {
|
||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||
return !utils.isUndefined(source[option]);
|
||||
return !utils$1.isUndefined(source[option]);
|
||||
});
|
||||
|
||||
const metaTokens = options.metaTokens;
|
||||
@@ -927,24 +927,24 @@ function toFormData(obj, formData, options) {
|
||||
const dots = options.dots;
|
||||
const indexes = options.indexes;
|
||||
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
||||
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
||||
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
||||
|
||||
if (!utils.isFunction(visitor)) {
|
||||
if (!utils$1.isFunction(visitor)) {
|
||||
throw new TypeError('visitor must be a function');
|
||||
}
|
||||
|
||||
function convertValue(value) {
|
||||
if (value === null) return '';
|
||||
|
||||
if (utils.isDate(value)) {
|
||||
if (utils$1.isDate(value)) {
|
||||
return value.toISOString();
|
||||
}
|
||||
|
||||
if (!useBlob && utils.isBlob(value)) {
|
||||
if (!useBlob && utils$1.isBlob(value)) {
|
||||
throw new AxiosError('Blob is not supported. Use a Buffer instead.');
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
|
||||
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
||||
return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
|
||||
}
|
||||
|
||||
@@ -965,20 +965,20 @@ function toFormData(obj, formData, options) {
|
||||
let arr = value;
|
||||
|
||||
if (value && !path && typeof value === 'object') {
|
||||
if (utils.endsWith(key, '{}')) {
|
||||
if (utils$1.endsWith(key, '{}')) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
key = metaTokens ? key : key.slice(0, -2);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
value = JSON.stringify(value);
|
||||
} else if (
|
||||
(utils.isArray(value) && isFlatArray(value)) ||
|
||||
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
||||
(utils$1.isArray(value) && isFlatArray(value)) ||
|
||||
((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
|
||||
)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
key = removeBrackets(key);
|
||||
|
||||
arr.forEach(function each(el, index) {
|
||||
!(utils.isUndefined(el) || el === null) && formData.append(
|
||||
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
|
||||
convertValue(el)
|
||||
@@ -1006,7 +1006,7 @@ function toFormData(obj, formData, options) {
|
||||
});
|
||||
|
||||
function build(value, path) {
|
||||
if (utils.isUndefined(value)) return;
|
||||
if (utils$1.isUndefined(value)) return;
|
||||
|
||||
if (stack.indexOf(value) !== -1) {
|
||||
throw Error('Circular reference detected in ' + path.join('.'));
|
||||
@@ -1014,9 +1014,9 @@ function toFormData(obj, formData, options) {
|
||||
|
||||
stack.push(value);
|
||||
|
||||
utils.forEach(value, function each(el, key) {
|
||||
const result = !(utils.isUndefined(el) || el === null) && visitor.call(
|
||||
formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
|
||||
utils$1.forEach(value, function each(el, key) {
|
||||
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
||||
formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
|
||||
);
|
||||
|
||||
if (result === true) {
|
||||
@@ -1027,7 +1027,7 @@ function toFormData(obj, formData, options) {
|
||||
stack.pop();
|
||||
}
|
||||
|
||||
if (!utils.isObject(obj)) {
|
||||
if (!utils$1.isObject(obj)) {
|
||||
throw new TypeError('data must be an object');
|
||||
}
|
||||
|
||||
@@ -1131,7 +1131,7 @@ function buildURL(url, params, options) {
|
||||
if (serializeFn) {
|
||||
serializedParams = serializeFn(params, options);
|
||||
} else {
|
||||
serializedParams = utils.isURLSearchParams(params) ?
|
||||
serializedParams = utils$1.isURLSearchParams(params) ?
|
||||
params.toString() :
|
||||
new AxiosURLSearchParams(params, options).toString(_encode);
|
||||
}
|
||||
@@ -1206,7 +1206,7 @@ class InterceptorManager {
|
||||
* @returns {void}
|
||||
*/
|
||||
forEach(fn) {
|
||||
utils.forEach(this.handlers, function forEachHandler(h) {
|
||||
utils$1.forEach(this.handlers, function forEachHandler(h) {
|
||||
if (h !== null) {
|
||||
fn(h);
|
||||
}
|
||||
@@ -1228,6 +1228,18 @@ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
|
||||
|
||||
var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
||||
|
||||
var platform$1 = {
|
||||
isBrowser: true,
|
||||
classes: {
|
||||
URLSearchParams: URLSearchParams$1,
|
||||
FormData: FormData$1,
|
||||
Blob: Blob$1
|
||||
},
|
||||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
||||
};
|
||||
|
||||
const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
*
|
||||
@@ -1245,18 +1257,10 @@ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
|
||||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isStandardBrowserEnv = (() => {
|
||||
let product;
|
||||
if (typeof navigator !== 'undefined' && (
|
||||
(product = navigator.product) === 'ReactNative' ||
|
||||
product === 'NativeScript' ||
|
||||
product === 'NS')
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
||||
})();
|
||||
const hasStandardBrowserEnv = (
|
||||
(product) => {
|
||||
return hasBrowserEnv && ['ReactNative', 'NativeScript', 'NS'].indexOf(product) < 0
|
||||
})(typeof navigator !== 'undefined' && navigator.product);
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser webWorker environment
|
||||
@@ -1267,7 +1271,7 @@ const isStandardBrowserEnv = (() => {
|
||||
* `typeof window !== 'undefined' && typeof document !== 'undefined'`.
|
||||
* This leads to a problem when axios post `FormData` in webWorker
|
||||
*/
|
||||
const isStandardBrowserWebWorkerEnv = (() => {
|
||||
const hasStandardBrowserWebWorkerEnv = (() => {
|
||||
return (
|
||||
typeof WorkerGlobalScope !== 'undefined' &&
|
||||
// eslint-disable-next-line no-undef
|
||||
@@ -1276,23 +1280,22 @@ const isStandardBrowserEnv = (() => {
|
||||
);
|
||||
})();
|
||||
|
||||
var utils = /*#__PURE__*/Object.freeze({
|
||||
__proto__: null,
|
||||
hasBrowserEnv: hasBrowserEnv,
|
||||
hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
|
||||
hasStandardBrowserEnv: hasStandardBrowserEnv
|
||||
});
|
||||
|
||||
var platform = {
|
||||
isBrowser: true,
|
||||
classes: {
|
||||
URLSearchParams: URLSearchParams$1,
|
||||
FormData: FormData$1,
|
||||
Blob: Blob$1
|
||||
},
|
||||
isStandardBrowserEnv,
|
||||
isStandardBrowserWebWorkerEnv,
|
||||
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
|
||||
...utils,
|
||||
...platform$1
|
||||
};
|
||||
|
||||
function toURLEncodedForm(data, options) {
|
||||
return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
|
||||
visitor: function(value, key, path, helpers) {
|
||||
if (platform.isNode && utils.isBuffer(value)) {
|
||||
if (platform.isNode && utils$1.isBuffer(value)) {
|
||||
this.append(key, value.toString('base64'));
|
||||
return false;
|
||||
}
|
||||
@@ -1314,7 +1317,7 @@ function parsePropPath(name) {
|
||||
// foo.x.y.z
|
||||
// foo-x-y-z
|
||||
// foo x y z
|
||||
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
||||
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
|
||||
return match[0] === '[]' ? '' : match[1] || match[0];
|
||||
});
|
||||
}
|
||||
@@ -1351,10 +1354,10 @@ function formDataToJSON(formData) {
|
||||
let name = path[index++];
|
||||
const isNumericKey = Number.isFinite(+name);
|
||||
const isLast = index >= path.length;
|
||||
name = !name && utils.isArray(target) ? target.length : name;
|
||||
name = !name && utils$1.isArray(target) ? target.length : name;
|
||||
|
||||
if (isLast) {
|
||||
if (utils.hasOwnProp(target, name)) {
|
||||
if (utils$1.hasOwnProp(target, name)) {
|
||||
target[name] = [target[name], value];
|
||||
} else {
|
||||
target[name] = value;
|
||||
@@ -1363,23 +1366,23 @@ function formDataToJSON(formData) {
|
||||
return !isNumericKey;
|
||||
}
|
||||
|
||||
if (!target[name] || !utils.isObject(target[name])) {
|
||||
if (!target[name] || !utils$1.isObject(target[name])) {
|
||||
target[name] = [];
|
||||
}
|
||||
|
||||
const result = buildPath(path, value, target[name], index);
|
||||
|
||||
if (result && utils.isArray(target[name])) {
|
||||
if (result && utils$1.isArray(target[name])) {
|
||||
target[name] = arrayToObject(target[name]);
|
||||
}
|
||||
|
||||
return !isNumericKey;
|
||||
}
|
||||
|
||||
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
||||
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
||||
const obj = {};
|
||||
|
||||
utils.forEachEntry(formData, (name, value) => {
|
||||
utils$1.forEachEntry(formData, (name, value) => {
|
||||
buildPath(parsePropPath(name), value, obj, 0);
|
||||
});
|
||||
|
||||
@@ -1400,10 +1403,10 @@ function formDataToJSON(formData) {
|
||||
* @returns {string} A stringified version of the rawValue.
|
||||
*/
|
||||
function stringifySafely(rawValue, parser, encoder) {
|
||||
if (utils.isString(rawValue)) {
|
||||
if (utils$1.isString(rawValue)) {
|
||||
try {
|
||||
(parser || JSON.parse)(rawValue);
|
||||
return utils.trim(rawValue);
|
||||
return utils$1.trim(rawValue);
|
||||
} catch (e) {
|
||||
if (e.name !== 'SyntaxError') {
|
||||
throw e;
|
||||
@@ -1423,13 +1426,13 @@ const defaults = {
|
||||
transformRequest: [function transformRequest(data, headers) {
|
||||
const contentType = headers.getContentType() || '';
|
||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||
const isObjectPayload = utils.isObject(data);
|
||||
const isObjectPayload = utils$1.isObject(data);
|
||||
|
||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
||||
data = new FormData(data);
|
||||
}
|
||||
|
||||
const isFormData = utils.isFormData(data);
|
||||
const isFormData = utils$1.isFormData(data);
|
||||
|
||||
if (isFormData) {
|
||||
if (!hasJSONContentType) {
|
||||
@@ -1438,18 +1441,18 @@ const defaults = {
|
||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data) ||
|
||||
utils.isBuffer(data) ||
|
||||
utils.isStream(data) ||
|
||||
utils.isFile(data) ||
|
||||
utils.isBlob(data)
|
||||
if (utils$1.isArrayBuffer(data) ||
|
||||
utils$1.isBuffer(data) ||
|
||||
utils$1.isStream(data) ||
|
||||
utils$1.isFile(data) ||
|
||||
utils$1.isBlob(data)
|
||||
) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
if (utils$1.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isURLSearchParams(data)) {
|
||||
if (utils$1.isURLSearchParams(data)) {
|
||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||
return data.toString();
|
||||
}
|
||||
@@ -1461,7 +1464,7 @@ const defaults = {
|
||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||
}
|
||||
|
||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||
if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||
const _FormData = this.env && this.env.FormData;
|
||||
|
||||
return toFormData(
|
||||
@@ -1485,7 +1488,7 @@ const defaults = {
|
||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||
const JSONRequested = this.responseType === 'json';
|
||||
|
||||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||
if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||
|
||||
@@ -1533,7 +1536,7 @@ const defaults = {
|
||||
}
|
||||
};
|
||||
|
||||
utils.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
||||
utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
|
||||
defaults.headers[method] = {};
|
||||
});
|
||||
|
||||
@@ -1541,7 +1544,7 @@ var defaults$1 = defaults;
|
||||
|
||||
// RawAxiosHeaders whose duplicates are ignored by node
|
||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||
const ignoreDuplicateOf = utils.toObjectSet([
|
||||
const ignoreDuplicateOf = utils$1.toObjectSet([
|
||||
'age', 'authorization', 'content-length', 'content-type', 'etag',
|
||||
'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
|
||||
'last-modified', 'location', 'max-forwards', 'proxy-authorization',
|
||||
@@ -1602,7 +1605,7 @@ function normalizeValue(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return utils.isArray(value) ? value.map(normalizeValue) : String(value);
|
||||
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
||||
}
|
||||
|
||||
function parseTokens(str) {
|
||||
@@ -1620,7 +1623,7 @@ function parseTokens(str) {
|
||||
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
||||
|
||||
function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
||||
if (utils.isFunction(filter)) {
|
||||
if (utils$1.isFunction(filter)) {
|
||||
return filter.call(this, value, header);
|
||||
}
|
||||
|
||||
@@ -1628,13 +1631,13 @@ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
|
||||
value = header;
|
||||
}
|
||||
|
||||
if (!utils.isString(value)) return;
|
||||
if (!utils$1.isString(value)) return;
|
||||
|
||||
if (utils.isString(filter)) {
|
||||
if (utils$1.isString(filter)) {
|
||||
return value.indexOf(filter) !== -1;
|
||||
}
|
||||
|
||||
if (utils.isRegExp(filter)) {
|
||||
if (utils$1.isRegExp(filter)) {
|
||||
return filter.test(value);
|
||||
}
|
||||
}
|
||||
@@ -1647,7 +1650,7 @@ function formatHeader(header) {
|
||||
}
|
||||
|
||||
function buildAccessors(obj, header) {
|
||||
const accessorName = utils.toCamelCase(' ' + header);
|
||||
const accessorName = utils$1.toCamelCase(' ' + header);
|
||||
|
||||
['get', 'set', 'has'].forEach(methodName => {
|
||||
Object.defineProperty(obj, methodName + accessorName, {
|
||||
@@ -1674,7 +1677,7 @@ class AxiosHeaders {
|
||||
throw new Error('header name must be a non-empty string');
|
||||
}
|
||||
|
||||
const key = utils.findKey(self, lHeader);
|
||||
const key = utils$1.findKey(self, lHeader);
|
||||
|
||||
if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
|
||||
self[key || _header] = normalizeValue(_value);
|
||||
@@ -1682,11 +1685,11 @@ class AxiosHeaders {
|
||||
}
|
||||
|
||||
const setHeaders = (headers, _rewrite) =>
|
||||
utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
||||
utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
||||
|
||||
if (utils.isPlainObject(header) || header instanceof this.constructor) {
|
||||
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
||||
setHeaders(header, valueOrRewrite);
|
||||
} else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
||||
} else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
||||
setHeaders(parseHeaders(header), valueOrRewrite);
|
||||
} else {
|
||||
header != null && setHeader(valueOrRewrite, header, rewrite);
|
||||
@@ -1699,7 +1702,7 @@ class AxiosHeaders {
|
||||
header = normalizeHeader(header);
|
||||
|
||||
if (header) {
|
||||
const key = utils.findKey(this, header);
|
||||
const key = utils$1.findKey(this, header);
|
||||
|
||||
if (key) {
|
||||
const value = this[key];
|
||||
@@ -1712,11 +1715,11 @@ class AxiosHeaders {
|
||||
return parseTokens(value);
|
||||
}
|
||||
|
||||
if (utils.isFunction(parser)) {
|
||||
if (utils$1.isFunction(parser)) {
|
||||
return parser.call(this, value, key);
|
||||
}
|
||||
|
||||
if (utils.isRegExp(parser)) {
|
||||
if (utils$1.isRegExp(parser)) {
|
||||
return parser.exec(value);
|
||||
}
|
||||
|
||||
@@ -1729,7 +1732,7 @@ class AxiosHeaders {
|
||||
header = normalizeHeader(header);
|
||||
|
||||
if (header) {
|
||||
const key = utils.findKey(this, header);
|
||||
const key = utils$1.findKey(this, header);
|
||||
|
||||
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
||||
}
|
||||
@@ -1745,7 +1748,7 @@ class AxiosHeaders {
|
||||
_header = normalizeHeader(_header);
|
||||
|
||||
if (_header) {
|
||||
const key = utils.findKey(self, _header);
|
||||
const key = utils$1.findKey(self, _header);
|
||||
|
||||
if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
|
||||
delete self[key];
|
||||
@@ -1755,7 +1758,7 @@ class AxiosHeaders {
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isArray(header)) {
|
||||
if (utils$1.isArray(header)) {
|
||||
header.forEach(deleteHeader);
|
||||
} else {
|
||||
deleteHeader(header);
|
||||
@@ -1784,8 +1787,8 @@ class AxiosHeaders {
|
||||
const self = this;
|
||||
const headers = {};
|
||||
|
||||
utils.forEach(this, (value, header) => {
|
||||
const key = utils.findKey(headers, header);
|
||||
utils$1.forEach(this, (value, header) => {
|
||||
const key = utils$1.findKey(headers, header);
|
||||
|
||||
if (key) {
|
||||
self[key] = normalizeValue(value);
|
||||
@@ -1814,8 +1817,8 @@ class AxiosHeaders {
|
||||
toJSON(asStrings) {
|
||||
const obj = Object.create(null);
|
||||
|
||||
utils.forEach(this, (value, header) => {
|
||||
value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
|
||||
utils$1.forEach(this, (value, header) => {
|
||||
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
|
||||
});
|
||||
|
||||
return obj;
|
||||
@@ -1862,7 +1865,7 @@ class AxiosHeaders {
|
||||
}
|
||||
}
|
||||
|
||||
utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
||||
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -1871,7 +1874,7 @@ class AxiosHeaders {
|
||||
AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
|
||||
|
||||
// reserved names hotfix
|
||||
utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
||||
utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
||||
let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
|
||||
return {
|
||||
get: () => value,
|
||||
@@ -1881,7 +1884,7 @@ utils.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
|
||||
}
|
||||
});
|
||||
|
||||
utils.freezeMethods(AxiosHeaders);
|
||||
utils$1.freezeMethods(AxiosHeaders);
|
||||
|
||||
var AxiosHeaders$1 = AxiosHeaders;
|
||||
|
||||
@@ -1899,7 +1902,7 @@ function transformData(fns, response) {
|
||||
const headers = AxiosHeaders$1.from(context.headers);
|
||||
let data = context.data;
|
||||
|
||||
utils.forEach(fns, function transform(fn) {
|
||||
utils$1.forEach(fns, function transform(fn) {
|
||||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
||||
});
|
||||
|
||||
@@ -1927,7 +1930,7 @@ function CanceledError(message, config, request) {
|
||||
this.name = 'CanceledError';
|
||||
}
|
||||
|
||||
utils.inherits(CanceledError, AxiosError, {
|
||||
utils$1.inherits(CanceledError, AxiosError, {
|
||||
__CANCEL__: true
|
||||
});
|
||||
|
||||
@@ -1955,7 +1958,7 @@ function settle(resolve, reject, response) {
|
||||
}
|
||||
}
|
||||
|
||||
var cookies = platform.isStandardBrowserEnv ?
|
||||
var cookies = platform.hasStandardBrowserEnv ?
|
||||
|
||||
// Standard browser envs support document.cookie
|
||||
(function standardBrowserEnv() {
|
||||
@@ -1964,15 +1967,15 @@ var cookies = platform.isStandardBrowserEnv ?
|
||||
const cookie = [];
|
||||
cookie.push(name + '=' + encodeURIComponent(value));
|
||||
|
||||
if (utils.isNumber(expires)) {
|
||||
if (utils$1.isNumber(expires)) {
|
||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||
}
|
||||
|
||||
if (utils.isString(path)) {
|
||||
if (utils$1.isString(path)) {
|
||||
cookie.push('path=' + path);
|
||||
}
|
||||
|
||||
if (utils.isString(domain)) {
|
||||
if (utils$1.isString(domain)) {
|
||||
cookie.push('domain=' + domain);
|
||||
}
|
||||
|
||||
@@ -2048,7 +2051,7 @@ function buildFullPath(baseURL, requestedURL) {
|
||||
return requestedURL;
|
||||
}
|
||||
|
||||
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
||||
var isURLSameOrigin = platform.hasStandardBrowserEnv ?
|
||||
|
||||
// Standard browser envs have full support of the APIs needed to test
|
||||
// whether the request URL is of the same origin as current location.
|
||||
@@ -2098,7 +2101,7 @@ var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||
*/
|
||||
return function isURLSameOrigin(requestURL) {
|
||||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
||||
const parsed = (utils$1.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
||||
return (parsed.protocol === originURL.protocol &&
|
||||
parsed.host === originURL.host);
|
||||
};
|
||||
@@ -2217,14 +2220,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||
|
||||
let contentType;
|
||||
|
||||
if (utils.isFormData(requestData)) {
|
||||
if (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv) {
|
||||
if (utils$1.isFormData(requestData)) {
|
||||
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
||||
requestHeaders.setContentType(false); // Let the browser set it
|
||||
} else if(!requestHeaders.getContentType(/^\s*multipart\/form-data/)){
|
||||
requestHeaders.setContentType('multipart/form-data'); // mobile/desktop app frameworks
|
||||
} else if(utils.isString(contentType = requestHeaders.getContentType())){
|
||||
} else if ((contentType = requestHeaders.getContentType()) !== false) {
|
||||
// fix semicolon duplication issue for ReactNative FormData implementation
|
||||
requestHeaders.setContentType(contentType.replace(/^\s*(multipart\/form-data);+/, '$1'));
|
||||
const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
|
||||
requestHeaders.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2340,7 +2342,7 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||
// Add xsrf header
|
||||
// This is only done if running in a standard browser environment.
|
||||
// Specifically not if we're in a web worker, or react-native.
|
||||
if (platform.isStandardBrowserEnv) {
|
||||
if (platform.hasStandardBrowserEnv) {
|
||||
// Add xsrf header
|
||||
// regarding CVE-2023-45857 config.withCredentials condition was removed temporarily
|
||||
const xsrfValue = isURLSameOrigin(fullPath) && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
|
||||
@@ -2355,13 +2357,13 @@ var xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||
|
||||
// Add headers to the request
|
||||
if ('setRequestHeader' in request) {
|
||||
utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||||
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
||||
request.setRequestHeader(key, val);
|
||||
});
|
||||
}
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (!utils.isUndefined(config.withCredentials)) {
|
||||
if (!utils$1.isUndefined(config.withCredentials)) {
|
||||
request.withCredentials = !!config.withCredentials;
|
||||
}
|
||||
|
||||
@@ -2416,7 +2418,7 @@ const knownAdapters = {
|
||||
xhr: xhrAdapter
|
||||
};
|
||||
|
||||
utils.forEach(knownAdapters, (fn, value) => {
|
||||
utils$1.forEach(knownAdapters, (fn, value) => {
|
||||
if (fn) {
|
||||
try {
|
||||
Object.defineProperty(fn, 'name', {value});
|
||||
@@ -2429,11 +2431,11 @@ utils.forEach(knownAdapters, (fn, value) => {
|
||||
|
||||
const renderReason = (reason) => `- ${reason}`;
|
||||
|
||||
const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === null || adapter === false;
|
||||
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
||||
|
||||
var adapters = {
|
||||
getAdapter: (adapters) => {
|
||||
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||
adapters = utils$1.isArray(adapters) ? adapters : [adapters];
|
||||
|
||||
const {length} = adapters;
|
||||
let nameOrAdapter;
|
||||
@@ -2574,11 +2576,11 @@ function mergeConfig(config1, config2) {
|
||||
const config = {};
|
||||
|
||||
function getMergedValue(target, source, caseless) {
|
||||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
||||
return utils.merge.call({caseless}, target, source);
|
||||
} else if (utils.isPlainObject(source)) {
|
||||
return utils.merge({}, source);
|
||||
} else if (utils.isArray(source)) {
|
||||
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
||||
return utils$1.merge.call({caseless}, target, source);
|
||||
} else if (utils$1.isPlainObject(source)) {
|
||||
return utils$1.merge({}, source);
|
||||
} else if (utils$1.isArray(source)) {
|
||||
return source.slice();
|
||||
}
|
||||
return source;
|
||||
@@ -2586,25 +2588,25 @@ function mergeConfig(config1, config2) {
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function mergeDeepProperties(a, b, caseless) {
|
||||
if (!utils.isUndefined(b)) {
|
||||
if (!utils$1.isUndefined(b)) {
|
||||
return getMergedValue(a, b, caseless);
|
||||
} else if (!utils.isUndefined(a)) {
|
||||
} else if (!utils$1.isUndefined(a)) {
|
||||
return getMergedValue(undefined, a, caseless);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function valueFromConfig2(a, b) {
|
||||
if (!utils.isUndefined(b)) {
|
||||
if (!utils$1.isUndefined(b)) {
|
||||
return getMergedValue(undefined, b);
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
function defaultToConfig2(a, b) {
|
||||
if (!utils.isUndefined(b)) {
|
||||
if (!utils$1.isUndefined(b)) {
|
||||
return getMergedValue(undefined, b);
|
||||
} else if (!utils.isUndefined(a)) {
|
||||
} else if (!utils$1.isUndefined(a)) {
|
||||
return getMergedValue(undefined, a);
|
||||
}
|
||||
}
|
||||
@@ -2649,16 +2651,16 @@ function mergeConfig(config1, config2) {
|
||||
headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
|
||||
};
|
||||
|
||||
utils.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
||||
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
||||
const merge = mergeMap[prop] || mergeDeepProperties;
|
||||
const configValue = merge(config1[prop], config2[prop], prop);
|
||||
(utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
||||
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
||||
});
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
const VERSION = "1.6.0";
|
||||
const VERSION = "1.6.1";
|
||||
|
||||
const validators$1 = {};
|
||||
|
||||
@@ -2796,7 +2798,7 @@ class Axios {
|
||||
}
|
||||
|
||||
if (paramsSerializer != null) {
|
||||
if (utils.isFunction(paramsSerializer)) {
|
||||
if (utils$1.isFunction(paramsSerializer)) {
|
||||
config.paramsSerializer = {
|
||||
serialize: paramsSerializer
|
||||
};
|
||||
@@ -2812,12 +2814,12 @@ class Axios {
|
||||
config.method = (config.method || this.defaults.method || 'get').toLowerCase();
|
||||
|
||||
// Flatten headers
|
||||
let contextHeaders = headers && utils.merge(
|
||||
let contextHeaders = headers && utils$1.merge(
|
||||
headers.common,
|
||||
headers[config.method]
|
||||
);
|
||||
|
||||
headers && utils.forEach(
|
||||
headers && utils$1.forEach(
|
||||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
||||
(method) => {
|
||||
delete headers[method];
|
||||
@@ -2904,7 +2906,7 @@ class Axios {
|
||||
}
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
||||
utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
|
||||
/*eslint func-names:0*/
|
||||
Axios.prototype[method] = function(url, config) {
|
||||
return this.request(mergeConfig(config || {}, {
|
||||
@@ -2915,7 +2917,7 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData
|
||||
};
|
||||
});
|
||||
|
||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||
utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||
/*eslint func-names:0*/
|
||||
|
||||
function generateHTTPMethod(isForm) {
|
||||
@@ -3091,7 +3093,7 @@ function spread(callback) {
|
||||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
|
||||
*/
|
||||
function isAxiosError(payload) {
|
||||
return utils.isObject(payload) && (payload.isAxiosError === true);
|
||||
return utils$1.isObject(payload) && (payload.isAxiosError === true);
|
||||
}
|
||||
|
||||
const HttpStatusCode = {
|
||||
@@ -3178,10 +3180,10 @@ function createInstance(defaultConfig) {
|
||||
const instance = bind(Axios$1.prototype.request, context);
|
||||
|
||||
// Copy axios.prototype to instance
|
||||
utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
||||
utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
|
||||
|
||||
// Copy context to instance
|
||||
utils.extend(instance, context, null, {allOwnKeys: true});
|
||||
utils$1.extend(instance, context, null, {allOwnKeys: true});
|
||||
|
||||
// Factory for creating new instances
|
||||
instance.create = function create(instanceConfig) {
|
||||
@@ -3225,7 +3227,7 @@ axios.mergeConfig = mergeConfig;
|
||||
|
||||
axios.AxiosHeaders = AxiosHeaders$1;
|
||||
|
||||
axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||||
axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
||||
|
||||
axios.getAdapter = adapters.getAdapter;
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user