mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
chore(release): 1.2.0
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "axios",
|
"name": "axios",
|
||||||
"main": "./dist/axios.js",
|
"main": "./dist/axios.js",
|
||||||
"version": "1.2.0-alpha.1",
|
"version": "1.2.0",
|
||||||
"homepage": "https://axios-http.com",
|
"homepage": "https://axios-http.com",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Matt Zabriskie"
|
"Matt Zabriskie"
|
||||||
|
|||||||
Vendored
+388
-355
@@ -1,4 +1,4 @@
|
|||||||
// Axios v1.2.0-alpha.1 Copyright (c) 2022 Matt Zabriskie and contributors
|
// Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
|
||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||||
typeof define === 'function' && define.amd ? define(factory) :
|
typeof define === 'function' && define.amd ? define(factory) :
|
||||||
@@ -666,6 +666,28 @@
|
|||||||
value = +value;
|
value = +value;
|
||||||
return Number.isFinite(value) ? value : defaultValue;
|
return Number.isFinite(value) ? value : defaultValue;
|
||||||
};
|
};
|
||||||
|
var toJSONObject = function toJSONObject(obj) {
|
||||||
|
var stack = new Array(10);
|
||||||
|
var visit = function visit(source, i) {
|
||||||
|
if (isObject(source)) {
|
||||||
|
if (stack.indexOf(source) >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!('toJSON' in source)) {
|
||||||
|
stack[i] = source;
|
||||||
|
var target = isArray(source) ? [] : {};
|
||||||
|
forEach(source, function (value, key) {
|
||||||
|
var reducedValue = visit(value, i + 1);
|
||||||
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
||||||
|
});
|
||||||
|
stack[i] = undefined;
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
};
|
||||||
|
return visit(obj, 0);
|
||||||
|
};
|
||||||
var utils = {
|
var utils = {
|
||||||
isArray: isArray,
|
isArray: isArray,
|
||||||
isArrayBuffer: isArrayBuffer,
|
isArrayBuffer: isArrayBuffer,
|
||||||
@@ -712,7 +734,8 @@
|
|||||||
toFiniteNumber: toFiniteNumber,
|
toFiniteNumber: toFiniteNumber,
|
||||||
findKey: findKey,
|
findKey: findKey,
|
||||||
global: _global,
|
global: _global,
|
||||||
isContextDefined: isContextDefined
|
isContextDefined: isContextDefined,
|
||||||
|
toJSONObject: toJSONObject
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -755,7 +778,7 @@
|
|||||||
columnNumber: this.columnNumber,
|
columnNumber: this.columnNumber,
|
||||||
stack: this.stack,
|
stack: this.stack,
|
||||||
// Axios
|
// Axios
|
||||||
config: this.config,
|
config: utils.toJSONObject(this.config),
|
||||||
code: this.code,
|
code: this.code,
|
||||||
status: this.response && this.response.status ? this.response.status : null
|
status: this.response && this.response.status ? this.response.status : null
|
||||||
};
|
};
|
||||||
@@ -1289,185 +1312,127 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
var DEFAULT_CONTENT_TYPE = {
|
||||||
* Resolve or reject a Promise based on response status.
|
'Content-Type': undefined
|
||||||
*
|
};
|
||||||
* @param {Function} resolve A function that resolves the promise.
|
|
||||||
* @param {Function} reject A function that rejects the promise.
|
|
||||||
* @param {object} response The response.
|
|
||||||
*
|
|
||||||
* @returns {object} The response.
|
|
||||||
*/
|
|
||||||
function settle(resolve, reject, response) {
|
|
||||||
var validateStatus = response.config.validateStatus;
|
|
||||||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
||||||
resolve(response);
|
|
||||||
} else {
|
|
||||||
reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var cookies = platform.isStandardBrowserEnv ?
|
/**
|
||||||
// Standard browser envs support document.cookie
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
||||||
function standardBrowserEnv() {
|
* of the input
|
||||||
return {
|
*
|
||||||
write: function write(name, value, expires, path, domain, secure) {
|
* @param {any} rawValue - The value to be stringified.
|
||||||
var cookie = [];
|
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
||||||
cookie.push(name + '=' + encodeURIComponent(value));
|
* @param {Function} encoder - A function that takes a value and returns a string.
|
||||||
if (utils.isNumber(expires)) {
|
*
|
||||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
* @returns {string} A stringified version of the rawValue.
|
||||||
|
*/
|
||||||
|
function stringifySafely(rawValue, parser, encoder) {
|
||||||
|
if (utils.isString(rawValue)) {
|
||||||
|
try {
|
||||||
|
(parser || JSON.parse)(rawValue);
|
||||||
|
return utils.trim(rawValue);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.name !== 'SyntaxError') {
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
if (utils.isString(path)) {
|
|
||||||
cookie.push('path=' + path);
|
|
||||||
}
|
|
||||||
if (utils.isString(domain)) {
|
|
||||||
cookie.push('domain=' + domain);
|
|
||||||
}
|
|
||||||
if (secure === true) {
|
|
||||||
cookie.push('secure');
|
|
||||||
}
|
|
||||||
document.cookie = cookie.join('; ');
|
|
||||||
},
|
|
||||||
read: function read(name) {
|
|
||||||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
||||||
return match ? decodeURIComponent(match[3]) : null;
|
|
||||||
},
|
|
||||||
remove: function remove(name) {
|
|
||||||
this.write(name, '', Date.now() - 86400000);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}() :
|
|
||||||
// Non standard browser env (web workers, react-native) lack needed support.
|
|
||||||
function nonStandardBrowserEnv() {
|
|
||||||
return {
|
|
||||||
write: function write() {},
|
|
||||||
read: function read() {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
remove: function remove() {}
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the specified URL is absolute
|
|
||||||
*
|
|
||||||
* @param {string} url The URL to test
|
|
||||||
*
|
|
||||||
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
||||||
*/
|
|
||||||
function isAbsoluteURL(url) {
|
|
||||||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
||||||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
||||||
// by any combination of letters, digits, plus, period, or hyphen.
|
|
||||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the specified URLs
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} relativeURL The relative URL
|
|
||||||
*
|
|
||||||
* @returns {string} The combined URL
|
|
||||||
*/
|
|
||||||
function combineURLs(baseURL, relativeURL) {
|
|
||||||
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
||||||
* only when the requestedURL is not already an absolute URL.
|
|
||||||
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} requestedURL Absolute or relative URL to combine
|
|
||||||
*
|
|
||||||
* @returns {string} The combined full path
|
|
||||||
*/
|
|
||||||
function buildFullPath(baseURL, requestedURL) {
|
|
||||||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
||||||
return combineURLs(baseURL, requestedURL);
|
|
||||||
}
|
}
|
||||||
return requestedURL;
|
return (encoder || JSON.stringify)(rawValue);
|
||||||
}
|
}
|
||||||
|
var defaults = {
|
||||||
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
transitional: transitionalDefaults,
|
||||||
// Standard browser envs have full support of the APIs needed to test
|
adapter: ['xhr', 'http'],
|
||||||
// whether the request URL is of the same origin as current location.
|
transformRequest: [function transformRequest(data, headers) {
|
||||||
function standardBrowserEnv() {
|
var contentType = headers.getContentType() || '';
|
||||||
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||||
var urlParsingNode = document.createElement('a');
|
var isObjectPayload = utils.isObject(data);
|
||||||
var originURL;
|
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||||
|
data = new FormData(data);
|
||||||
/**
|
|
||||||
* Parse a URL to discover it's components
|
|
||||||
*
|
|
||||||
* @param {String} url The URL to be parsed
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
function resolveURL(url) {
|
|
||||||
var href = url;
|
|
||||||
if (msie) {
|
|
||||||
// IE needs attribute set twice to normalize properties
|
|
||||||
urlParsingNode.setAttribute('href', href);
|
|
||||||
href = urlParsingNode.href;
|
|
||||||
}
|
}
|
||||||
urlParsingNode.setAttribute('href', href);
|
var isFormData = utils.isFormData(data);
|
||||||
|
if (isFormData) {
|
||||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
if (!hasJSONContentType) {
|
||||||
return {
|
return data;
|
||||||
href: urlParsingNode.href,
|
}
|
||||||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||||
host: urlParsingNode.host,
|
}
|
||||||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
||||||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
return data;
|
||||||
hostname: urlParsingNode.hostname,
|
}
|
||||||
port: urlParsingNode.port,
|
if (utils.isArrayBufferView(data)) {
|
||||||
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
return data.buffer;
|
||||||
};
|
}
|
||||||
}
|
if (utils.isURLSearchParams(data)) {
|
||||||
originURL = resolveURL(window.location.href);
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
var isFileList;
|
||||||
|
if (isObjectPayload) {
|
||||||
|
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||||
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||||
|
}
|
||||||
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||||
|
var _FormData = this.env && this.env.FormData;
|
||||||
|
return toFormData(isFileList ? {
|
||||||
|
'files[]': data
|
||||||
|
} : data, _FormData && new _FormData(), this.formSerializer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isObjectPayload || hasJSONContentType) {
|
||||||
|
headers.setContentType('application/json', false);
|
||||||
|
return stringifySafely(data);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
transformResponse: [function transformResponse(data) {
|
||||||
|
var transitional = this.transitional || defaults.transitional;
|
||||||
|
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||||
|
var JSONRequested = this.responseType === 'json';
|
||||||
|
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
||||||
|
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||||
|
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||||
|
try {
|
||||||
|
return JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
if (strictJSONParsing) {
|
||||||
|
if (e.name === 'SyntaxError') {
|
||||||
|
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
/**
|
/**
|
||||||
* Determine if a URL shares the same origin as the current location
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||||
*
|
* timeout is not created.
|
||||||
* @param {String} requestURL The URL to test
|
*/
|
||||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
timeout: 0,
|
||||||
*/
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
return function isURLSameOrigin(requestURL) {
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||||||
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
maxContentLength: -1,
|
||||||
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
maxBodyLength: -1,
|
||||||
};
|
env: {
|
||||||
}() :
|
FormData: platform.classes.FormData,
|
||||||
// Non standard browser envs (web workers, react-native) lack needed support.
|
Blob: platform.classes.Blob
|
||||||
function nonStandardBrowserEnv() {
|
},
|
||||||
return function isURLSameOrigin() {
|
validateStatus: function validateStatus(status) {
|
||||||
return true;
|
return status >= 200 && status < 300;
|
||||||
};
|
},
|
||||||
}();
|
headers: {
|
||||||
|
common: {
|
||||||
/**
|
'Accept': 'application/json, text/plain, */*'
|
||||||
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
}
|
||||||
*
|
}
|
||||||
* @param {string=} message The message.
|
};
|
||||||
* @param {Object=} config The config.
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||||||
* @param {Object=} request The request.
|
defaults.headers[method] = {};
|
||||||
*
|
|
||||||
* @returns {CanceledError} The created error.
|
|
||||||
*/
|
|
||||||
function CanceledError(message, config, request) {
|
|
||||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
||||||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
||||||
this.name = 'CanceledError';
|
|
||||||
}
|
|
||||||
utils.inherits(CanceledError, AxiosError, {
|
|
||||||
__CANCEL__: true
|
|
||||||
});
|
});
|
||||||
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||||
function parseProtocol(url) {
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||||||
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
});
|
||||||
return match && match[1] || '';
|
var defaults$1 = defaults;
|
||||||
}
|
|
||||||
|
|
||||||
// RawAxiosHeaders whose duplicates are ignored by node
|
// RawAxiosHeaders whose duplicates are ignored by node
|
||||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||||
@@ -1758,6 +1723,213 @@
|
|||||||
utils.freezeMethods(AxiosHeaders);
|
utils.freezeMethods(AxiosHeaders);
|
||||||
var AxiosHeaders$1 = AxiosHeaders;
|
var AxiosHeaders$1 = AxiosHeaders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the data for a request or a response
|
||||||
|
*
|
||||||
|
* @param {Array|Function} fns A single function or Array of functions
|
||||||
|
* @param {?Object} response The response object
|
||||||
|
*
|
||||||
|
* @returns {*} The resulting transformed data
|
||||||
|
*/
|
||||||
|
function transformData(fns, response) {
|
||||||
|
var config = this || defaults$1;
|
||||||
|
var context = response || config;
|
||||||
|
var headers = AxiosHeaders$1.from(context.headers);
|
||||||
|
var data = context.data;
|
||||||
|
utils.forEach(fns, function transform(fn) {
|
||||||
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
||||||
|
});
|
||||||
|
headers.normalize();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCancel(value) {
|
||||||
|
return !!(value && value.__CANCEL__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
||||||
|
*
|
||||||
|
* @param {string=} message The message.
|
||||||
|
* @param {Object=} config The config.
|
||||||
|
* @param {Object=} request The request.
|
||||||
|
*
|
||||||
|
* @returns {CanceledError} The created error.
|
||||||
|
*/
|
||||||
|
function CanceledError(message, config, request) {
|
||||||
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||||
|
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
||||||
|
this.name = 'CanceledError';
|
||||||
|
}
|
||||||
|
utils.inherits(CanceledError, AxiosError, {
|
||||||
|
__CANCEL__: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line strict
|
||||||
|
var httpAdapter = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve or reject a Promise based on response status.
|
||||||
|
*
|
||||||
|
* @param {Function} resolve A function that resolves the promise.
|
||||||
|
* @param {Function} reject A function that rejects the promise.
|
||||||
|
* @param {object} response The response.
|
||||||
|
*
|
||||||
|
* @returns {object} The response.
|
||||||
|
*/
|
||||||
|
function settle(resolve, reject, response) {
|
||||||
|
var validateStatus = response.config.validateStatus;
|
||||||
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||||||
|
resolve(response);
|
||||||
|
} else {
|
||||||
|
reject(new AxiosError('Request failed with status code ' + response.status, [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var cookies = platform.isStandardBrowserEnv ?
|
||||||
|
// Standard browser envs support document.cookie
|
||||||
|
function standardBrowserEnv() {
|
||||||
|
return {
|
||||||
|
write: function write(name, value, expires, path, domain, secure) {
|
||||||
|
var cookie = [];
|
||||||
|
cookie.push(name + '=' + encodeURIComponent(value));
|
||||||
|
if (utils.isNumber(expires)) {
|
||||||
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||||
|
}
|
||||||
|
if (utils.isString(path)) {
|
||||||
|
cookie.push('path=' + path);
|
||||||
|
}
|
||||||
|
if (utils.isString(domain)) {
|
||||||
|
cookie.push('domain=' + domain);
|
||||||
|
}
|
||||||
|
if (secure === true) {
|
||||||
|
cookie.push('secure');
|
||||||
|
}
|
||||||
|
document.cookie = cookie.join('; ');
|
||||||
|
},
|
||||||
|
read: function read(name) {
|
||||||
|
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||||
|
return match ? decodeURIComponent(match[3]) : null;
|
||||||
|
},
|
||||||
|
remove: function remove(name) {
|
||||||
|
this.write(name, '', Date.now() - 86400000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}() :
|
||||||
|
// Non standard browser env (web workers, react-native) lack needed support.
|
||||||
|
function nonStandardBrowserEnv() {
|
||||||
|
return {
|
||||||
|
write: function write() {},
|
||||||
|
read: function read() {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
remove: function remove() {}
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified URL is absolute
|
||||||
|
*
|
||||||
|
* @param {string} url The URL to test
|
||||||
|
*
|
||||||
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||||||
|
*/
|
||||||
|
function isAbsoluteURL(url) {
|
||||||
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||||||
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||||||
|
// by any combination of letters, digits, plus, period, or hyphen.
|
||||||
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the specified URLs
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} relativeURL The relative URL
|
||||||
|
*
|
||||||
|
* @returns {string} The combined URL
|
||||||
|
*/
|
||||||
|
function combineURLs(baseURL, relativeURL) {
|
||||||
|
return relativeURL ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
||||||
|
* only when the requestedURL is not already an absolute URL.
|
||||||
|
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} requestedURL Absolute or relative URL to combine
|
||||||
|
*
|
||||||
|
* @returns {string} The combined full path
|
||||||
|
*/
|
||||||
|
function buildFullPath(baseURL, requestedURL) {
|
||||||
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||||||
|
return combineURLs(baseURL, requestedURL);
|
||||||
|
}
|
||||||
|
return requestedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
||||||
|
// Standard browser envs have full support of the APIs needed to test
|
||||||
|
// whether the request URL is of the same origin as current location.
|
||||||
|
function standardBrowserEnv() {
|
||||||
|
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||||
|
var urlParsingNode = document.createElement('a');
|
||||||
|
var originURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a URL to discover it's components
|
||||||
|
*
|
||||||
|
* @param {String} url The URL to be parsed
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
function resolveURL(url) {
|
||||||
|
var href = url;
|
||||||
|
if (msie) {
|
||||||
|
// IE needs attribute set twice to normalize properties
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
href = urlParsingNode.href;
|
||||||
|
}
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
|
||||||
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||||
|
return {
|
||||||
|
href: urlParsingNode.href,
|
||||||
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||||
|
host: urlParsingNode.host,
|
||||||
|
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||||
|
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||||
|
hostname: urlParsingNode.hostname,
|
||||||
|
port: urlParsingNode.port,
|
||||||
|
pathname: urlParsingNode.pathname.charAt(0) === '/' ? urlParsingNode.pathname : '/' + urlParsingNode.pathname
|
||||||
|
};
|
||||||
|
}
|
||||||
|
originURL = resolveURL(window.location.href);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a URL shares the same origin as the current location
|
||||||
|
*
|
||||||
|
* @param {String} requestURL The URL to test
|
||||||
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||||
|
*/
|
||||||
|
return function isURLSameOrigin(requestURL) {
|
||||||
|
var parsed = utils.isString(requestURL) ? resolveURL(requestURL) : requestURL;
|
||||||
|
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
|
||||||
|
};
|
||||||
|
}() :
|
||||||
|
// Non standard browser envs (web workers, react-native) lack needed support.
|
||||||
|
function nonStandardBrowserEnv() {
|
||||||
|
return function isURLSameOrigin() {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
|
||||||
|
function parseProtocol(url) {
|
||||||
|
var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||||
|
return match && match[1] || '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate data maxRate
|
* Calculate data maxRate
|
||||||
* @param {Number} [samplesCount= 10]
|
* @param {Number} [samplesCount= 10]
|
||||||
@@ -1821,7 +1993,8 @@
|
|||||||
listener(data);
|
listener(data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function xhrAdapter(config) {
|
var isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||||
|
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||||
var requestData = config.data;
|
var requestData = config.data;
|
||||||
var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
var requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
||||||
@@ -2000,193 +2173,53 @@
|
|||||||
// Send the request
|
// Send the request
|
||||||
request.send(requestData || null);
|
request.send(requestData || null);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
var adapters = {
|
var knownAdapters = {
|
||||||
http: xhrAdapter,
|
http: httpAdapter,
|
||||||
xhr: xhrAdapter
|
xhr: xhrAdapter
|
||||||
};
|
};
|
||||||
var adapters$1 = {
|
utils.forEach(knownAdapters, function (fn, value) {
|
||||||
getAdapter: function getAdapter(nameOrAdapter) {
|
if (fn) {
|
||||||
if (utils.isString(nameOrAdapter)) {
|
try {
|
||||||
var adapter = adapters[nameOrAdapter];
|
Object.defineProperty(fn, 'name', {
|
||||||
if (!nameOrAdapter) {
|
value: value
|
||||||
throw Error(utils.hasOwnProp(nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Can not resolve adapter '".concat(nameOrAdapter, "'"));
|
});
|
||||||
}
|
} catch (e) {
|
||||||
return adapter;
|
// eslint-disable-next-line no-empty
|
||||||
}
|
}
|
||||||
if (!utils.isFunction(nameOrAdapter)) {
|
Object.defineProperty(fn, 'adapterName', {
|
||||||
|
value: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var adapters = {
|
||||||
|
getAdapter: function getAdapter(adapters) {
|
||||||
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||||
|
var _adapters = adapters,
|
||||||
|
length = _adapters.length;
|
||||||
|
var nameOrAdapter;
|
||||||
|
var adapter;
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
nameOrAdapter = adapters[i];
|
||||||
|
if (adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!adapter) {
|
||||||
|
if (adapter === false) {
|
||||||
|
throw new AxiosError("Adapter ".concat(nameOrAdapter, " is not supported by the environment"), 'ERR_NOT_SUPPORT');
|
||||||
|
}
|
||||||
|
throw new Error(utils.hasOwnProp(knownAdapters, nameOrAdapter) ? "Adapter '".concat(nameOrAdapter, "' is not available in the build") : "Unknown adapter '".concat(nameOrAdapter, "'"));
|
||||||
|
}
|
||||||
|
if (!utils.isFunction(adapter)) {
|
||||||
throw new TypeError('adapter is not a function');
|
throw new TypeError('adapter is not a function');
|
||||||
}
|
}
|
||||||
return nameOrAdapter;
|
return adapter;
|
||||||
},
|
},
|
||||||
adapters: adapters
|
adapters: knownAdapters
|
||||||
};
|
};
|
||||||
|
|
||||||
var DEFAULT_CONTENT_TYPE = {
|
|
||||||
'Content-Type': undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
|
||||||
* adapter
|
|
||||||
*
|
|
||||||
* @returns {Function}
|
|
||||||
*/
|
|
||||||
function getDefaultAdapter() {
|
|
||||||
var adapter;
|
|
||||||
if (typeof XMLHttpRequest !== 'undefined') {
|
|
||||||
// For browsers use XHR adapter
|
|
||||||
adapter = adapters$1.getAdapter('xhr');
|
|
||||||
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
|
||||||
// For node use HTTP adapter
|
|
||||||
adapter = adapters$1.getAdapter('http');
|
|
||||||
}
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
||||||
* of the input
|
|
||||||
*
|
|
||||||
* @param {any} rawValue - The value to be stringified.
|
|
||||||
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
||||||
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
||||||
*
|
|
||||||
* @returns {string} A stringified version of the rawValue.
|
|
||||||
*/
|
|
||||||
function stringifySafely(rawValue, parser, encoder) {
|
|
||||||
if (utils.isString(rawValue)) {
|
|
||||||
try {
|
|
||||||
(parser || JSON.parse)(rawValue);
|
|
||||||
return utils.trim(rawValue);
|
|
||||||
} catch (e) {
|
|
||||||
if (e.name !== 'SyntaxError') {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (encoder || JSON.stringify)(rawValue);
|
|
||||||
}
|
|
||||||
var defaults = {
|
|
||||||
transitional: transitionalDefaults,
|
|
||||||
adapter: getDefaultAdapter(),
|
|
||||||
transformRequest: [function transformRequest(data, headers) {
|
|
||||||
var contentType = headers.getContentType() || '';
|
|
||||||
var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
||||||
var isObjectPayload = utils.isObject(data);
|
|
||||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
||||||
data = new FormData(data);
|
|
||||||
}
|
|
||||||
var isFormData = utils.isFormData(data);
|
|
||||||
if (isFormData) {
|
|
||||||
if (!hasJSONContentType) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
||||||
}
|
|
||||||
if (utils.isArrayBuffer(data) || utils.isBuffer(data) || utils.isStream(data) || utils.isFile(data) || utils.isBlob(data)) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
if (utils.isArrayBufferView(data)) {
|
|
||||||
return data.buffer;
|
|
||||||
}
|
|
||||||
if (utils.isURLSearchParams(data)) {
|
|
||||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
||||||
return data.toString();
|
|
||||||
}
|
|
||||||
var isFileList;
|
|
||||||
if (isObjectPayload) {
|
|
||||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
||||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
||||||
}
|
|
||||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
||||||
var _FormData = this.env && this.env.FormData;
|
|
||||||
return toFormData(isFileList ? {
|
|
||||||
'files[]': data
|
|
||||||
} : data, _FormData && new _FormData(), this.formSerializer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isObjectPayload || hasJSONContentType) {
|
|
||||||
headers.setContentType('application/json', false);
|
|
||||||
return stringifySafely(data);
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
transformResponse: [function transformResponse(data) {
|
|
||||||
var transitional = this.transitional || defaults.transitional;
|
|
||||||
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
||||||
var JSONRequested = this.responseType === 'json';
|
|
||||||
if (data && utils.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
|
||||||
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
||||||
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
||||||
try {
|
|
||||||
return JSON.parse(data);
|
|
||||||
} catch (e) {
|
|
||||||
if (strictJSONParsing) {
|
|
||||||
if (e.name === 'SyntaxError') {
|
|
||||||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
/**
|
|
||||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
||||||
* timeout is not created.
|
|
||||||
*/
|
|
||||||
timeout: 0,
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
|
||||||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
||||||
maxContentLength: -1,
|
|
||||||
maxBodyLength: -1,
|
|
||||||
env: {
|
|
||||||
FormData: platform.classes.FormData,
|
|
||||||
Blob: platform.classes.Blob
|
|
||||||
},
|
|
||||||
validateStatus: function validateStatus(status) {
|
|
||||||
return status >= 200 && status < 300;
|
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
common: {
|
|
||||||
'Accept': 'application/json, text/plain, */*'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
||||||
defaults.headers[method] = {};
|
|
||||||
});
|
|
||||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
||||||
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
||||||
});
|
|
||||||
var defaults$1 = defaults;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the data for a request or a response
|
|
||||||
*
|
|
||||||
* @param {Array|Function} fns A single function or Array of functions
|
|
||||||
* @param {?Object} response The response object
|
|
||||||
*
|
|
||||||
* @returns {*} The resulting transformed data
|
|
||||||
*/
|
|
||||||
function transformData(fns, response) {
|
|
||||||
var config = this || defaults$1;
|
|
||||||
var context = response || config;
|
|
||||||
var headers = AxiosHeaders$1.from(context.headers);
|
|
||||||
var data = context.data;
|
|
||||||
utils.forEach(fns, function transform(fn) {
|
|
||||||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
||||||
});
|
|
||||||
headers.normalize();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCancel(value) {
|
|
||||||
return !!(value && value.__CANCEL__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws a `CanceledError` if cancellation has been requested.
|
* Throws a `CanceledError` if cancellation has been requested.
|
||||||
*
|
*
|
||||||
@@ -2219,7 +2252,7 @@
|
|||||||
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
|
||||||
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
||||||
}
|
}
|
||||||
var adapter = config.adapter || defaults$1.adapter;
|
var adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
||||||
return adapter(config).then(function onAdapterResolution(response) {
|
return adapter(config).then(function onAdapterResolution(response) {
|
||||||
throwIfCancellationRequested(config);
|
throwIfCancellationRequested(config);
|
||||||
|
|
||||||
@@ -2344,7 +2377,7 @@
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
var VERSION = "1.2.0-alpha.1";
|
var VERSION = "1.2.0";
|
||||||
|
|
||||||
var validators$1 = {};
|
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
+451
-407
@@ -1,4 +1,4 @@
|
|||||||
// Axios v1.2.0-alpha.1 Copyright (c) 2022 Matt Zabriskie and contributors
|
// Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function bind(fn, thisArg) {
|
function bind(fn, thisArg) {
|
||||||
@@ -597,6 +597,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|||||||
return Number.isFinite(value) ? value : defaultValue;
|
return Number.isFinite(value) ? value : defaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toJSONObject = (obj) => {
|
||||||
|
const stack = new Array(10);
|
||||||
|
|
||||||
|
const visit = (source, i) => {
|
||||||
|
|
||||||
|
if (isObject(source)) {
|
||||||
|
if (stack.indexOf(source) >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!('toJSON' in source)) {
|
||||||
|
stack[i] = source;
|
||||||
|
const target = isArray(source) ? [] : {};
|
||||||
|
|
||||||
|
forEach(source, (value, key) => {
|
||||||
|
const reducedValue = visit(value, i + 1);
|
||||||
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
stack[i] = undefined;
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
};
|
||||||
|
|
||||||
|
return visit(obj, 0);
|
||||||
|
};
|
||||||
|
|
||||||
var utils = {
|
var utils = {
|
||||||
isArray,
|
isArray,
|
||||||
isArrayBuffer,
|
isArrayBuffer,
|
||||||
@@ -642,7 +673,8 @@ var utils = {
|
|||||||
toFiniteNumber,
|
toFiniteNumber,
|
||||||
findKey,
|
findKey,
|
||||||
global: _global,
|
global: _global,
|
||||||
isContextDefined
|
isContextDefined,
|
||||||
|
toJSONObject
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -688,7 +720,7 @@ utils.inherits(AxiosError, Error, {
|
|||||||
columnNumber: this.columnNumber,
|
columnNumber: this.columnNumber,
|
||||||
stack: this.stack,
|
stack: this.stack,
|
||||||
// Axios
|
// Axios
|
||||||
config: this.config,
|
config: utils.toJSONObject(this.config),
|
||||||
code: this.code,
|
code: this.code,
|
||||||
status: this.response && this.response.status ? this.response.status : null
|
status: this.response && this.response.status ? this.response.status : null
|
||||||
};
|
};
|
||||||
@@ -1298,209 +1330,162 @@ function formDataToJSON(formData) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_CONTENT_TYPE = {
|
||||||
|
'Content-Type': undefined
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve or reject a Promise based on response status.
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
||||||
|
* of the input
|
||||||
*
|
*
|
||||||
* @param {Function} resolve A function that resolves the promise.
|
* @param {any} rawValue - The value to be stringified.
|
||||||
* @param {Function} reject A function that rejects the promise.
|
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
||||||
* @param {object} response The response.
|
* @param {Function} encoder - A function that takes a value and returns a string.
|
||||||
*
|
*
|
||||||
* @returns {object} The response.
|
* @returns {string} A stringified version of the rawValue.
|
||||||
*/
|
*/
|
||||||
function settle(resolve, reject, response) {
|
function stringifySafely(rawValue, parser, encoder) {
|
||||||
const validateStatus = response.config.validateStatus;
|
if (utils.isString(rawValue)) {
|
||||||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
try {
|
||||||
resolve(response);
|
(parser || JSON.parse)(rawValue);
|
||||||
} else {
|
return utils.trim(rawValue);
|
||||||
reject(new AxiosError(
|
} catch (e) {
|
||||||
'Request failed with status code ' + response.status,
|
if (e.name !== 'SyntaxError') {
|
||||||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
throw e;
|
||||||
response.config,
|
|
||||||
response.request,
|
|
||||||
response
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var cookies = platform.isStandardBrowserEnv ?
|
|
||||||
|
|
||||||
// Standard browser envs support document.cookie
|
|
||||||
(function standardBrowserEnv() {
|
|
||||||
return {
|
|
||||||
write: function write(name, value, expires, path, domain, secure) {
|
|
||||||
const cookie = [];
|
|
||||||
cookie.push(name + '=' + encodeURIComponent(value));
|
|
||||||
|
|
||||||
if (utils.isNumber(expires)) {
|
|
||||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isString(path)) {
|
|
||||||
cookie.push('path=' + path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isString(domain)) {
|
|
||||||
cookie.push('domain=' + domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secure === true) {
|
|
||||||
cookie.push('secure');
|
|
||||||
}
|
|
||||||
|
|
||||||
document.cookie = cookie.join('; ');
|
|
||||||
},
|
|
||||||
|
|
||||||
read: function read(name) {
|
|
||||||
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
||||||
return (match ? decodeURIComponent(match[3]) : null);
|
|
||||||
},
|
|
||||||
|
|
||||||
remove: function remove(name) {
|
|
||||||
this.write(name, '', Date.now() - 86400000);
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
})() :
|
|
||||||
|
|
||||||
// Non standard browser env (web workers, react-native) lack needed support.
|
|
||||||
(function nonStandardBrowserEnv() {
|
|
||||||
return {
|
|
||||||
write: function write() {},
|
|
||||||
read: function read() { return null; },
|
|
||||||
remove: function remove() {}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the specified URL is absolute
|
|
||||||
*
|
|
||||||
* @param {string} url The URL to test
|
|
||||||
*
|
|
||||||
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
||||||
*/
|
|
||||||
function isAbsoluteURL(url) {
|
|
||||||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
||||||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
||||||
// by any combination of letters, digits, plus, period, or hyphen.
|
|
||||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the specified URLs
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} relativeURL The relative URL
|
|
||||||
*
|
|
||||||
* @returns {string} The combined URL
|
|
||||||
*/
|
|
||||||
function combineURLs(baseURL, relativeURL) {
|
|
||||||
return relativeURL
|
|
||||||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
||||||
: baseURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
||||||
* only when the requestedURL is not already an absolute URL.
|
|
||||||
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} requestedURL Absolute or relative URL to combine
|
|
||||||
*
|
|
||||||
* @returns {string} The combined full path
|
|
||||||
*/
|
|
||||||
function buildFullPath(baseURL, requestedURL) {
|
|
||||||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
||||||
return combineURLs(baseURL, requestedURL);
|
|
||||||
}
|
}
|
||||||
return requestedURL;
|
|
||||||
|
return (encoder || JSON.stringify)(rawValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
const defaults = {
|
||||||
|
|
||||||
// Standard browser envs have full support of the APIs needed to test
|
transitional: transitionalDefaults,
|
||||||
// whether the request URL is of the same origin as current location.
|
|
||||||
(function standardBrowserEnv() {
|
|
||||||
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
||||||
const urlParsingNode = document.createElement('a');
|
|
||||||
let originURL;
|
|
||||||
|
|
||||||
/**
|
adapter: ['xhr', 'http'],
|
||||||
* Parse a URL to discover it's components
|
|
||||||
*
|
|
||||||
* @param {String} url The URL to be parsed
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
function resolveURL(url) {
|
|
||||||
let href = url;
|
|
||||||
|
|
||||||
if (msie) {
|
transformRequest: [function transformRequest(data, headers) {
|
||||||
// IE needs attribute set twice to normalize properties
|
const contentType = headers.getContentType() || '';
|
||||||
urlParsingNode.setAttribute('href', href);
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||||
href = urlParsingNode.href;
|
const isObjectPayload = utils.isObject(data);
|
||||||
}
|
|
||||||
|
|
||||||
urlParsingNode.setAttribute('href', href);
|
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||||
|
data = new FormData(data);
|
||||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
|
||||||
return {
|
|
||||||
href: urlParsingNode.href,
|
|
||||||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
|
||||||
host: urlParsingNode.host,
|
|
||||||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
|
||||||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
|
||||||
hostname: urlParsingNode.hostname,
|
|
||||||
port: urlParsingNode.port,
|
|
||||||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
|
||||||
urlParsingNode.pathname :
|
|
||||||
'/' + urlParsingNode.pathname
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
originURL = resolveURL(window.location.href);
|
const isFormData = utils.isFormData(data);
|
||||||
|
|
||||||
/**
|
if (isFormData) {
|
||||||
* Determine if a URL shares the same origin as the current location
|
if (!hasJSONContentType) {
|
||||||
*
|
return data;
|
||||||
* @param {String} requestURL The URL to test
|
}
|
||||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||||
*/
|
}
|
||||||
return function isURLSameOrigin(requestURL) {
|
|
||||||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
||||||
return (parsed.protocol === originURL.protocol &&
|
|
||||||
parsed.host === originURL.host);
|
|
||||||
};
|
|
||||||
})() :
|
|
||||||
|
|
||||||
// Non standard browser envs (web workers, react-native) lack needed support.
|
if (utils.isArrayBuffer(data) ||
|
||||||
(function nonStandardBrowserEnv() {
|
utils.isBuffer(data) ||
|
||||||
return function isURLSameOrigin() {
|
utils.isStream(data) ||
|
||||||
return true;
|
utils.isFile(data) ||
|
||||||
};
|
utils.isBlob(data)
|
||||||
})();
|
) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
if (utils.isArrayBufferView(data)) {
|
||||||
|
return data.buffer;
|
||||||
|
}
|
||||||
|
if (utils.isURLSearchParams(data)) {
|
||||||
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
let isFileList;
|
||||||
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
||||||
*
|
|
||||||
* @param {string=} message The message.
|
|
||||||
* @param {Object=} config The config.
|
|
||||||
* @param {Object=} request The request.
|
|
||||||
*
|
|
||||||
* @returns {CanceledError} The created error.
|
|
||||||
*/
|
|
||||||
function CanceledError(message, config, request) {
|
|
||||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
||||||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
||||||
this.name = 'CanceledError';
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.inherits(CanceledError, AxiosError, {
|
if (isObjectPayload) {
|
||||||
__CANCEL__: true
|
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||||
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||||
|
const _FormData = this.env && this.env.FormData;
|
||||||
|
|
||||||
|
return toFormData(
|
||||||
|
isFileList ? {'files[]': data} : data,
|
||||||
|
_FormData && new _FormData(),
|
||||||
|
this.formSerializer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isObjectPayload || hasJSONContentType ) {
|
||||||
|
headers.setContentType('application/json', false);
|
||||||
|
return stringifySafely(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
|
||||||
|
transformResponse: [function transformResponse(data) {
|
||||||
|
const transitional = this.transitional || defaults.transitional;
|
||||||
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||||
|
const JSONRequested = this.responseType === 'json';
|
||||||
|
|
||||||
|
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||||
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||||
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
if (strictJSONParsing) {
|
||||||
|
if (e.name === 'SyntaxError') {
|
||||||
|
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||||
|
* timeout is not created.
|
||||||
|
*/
|
||||||
|
timeout: 0,
|
||||||
|
|
||||||
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||||||
|
|
||||||
|
maxContentLength: -1,
|
||||||
|
maxBodyLength: -1,
|
||||||
|
|
||||||
|
env: {
|
||||||
|
FormData: platform.classes.FormData,
|
||||||
|
Blob: platform.classes.Blob
|
||||||
|
},
|
||||||
|
|
||||||
|
validateStatus: function validateStatus(status) {
|
||||||
|
return status >= 200 && status < 300;
|
||||||
|
},
|
||||||
|
|
||||||
|
headers: {
|
||||||
|
common: {
|
||||||
|
'Accept': 'application/json, text/plain, */*'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||||||
|
defaults.headers[method] = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
function parseProtocol(url) {
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||||||
return match && match[1] || '';
|
});
|
||||||
}
|
|
||||||
|
var defaults$1 = defaults;
|
||||||
|
|
||||||
// RawAxiosHeaders whose duplicates are ignored by node
|
// RawAxiosHeaders whose duplicates are ignored by node
|
||||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||||
@@ -1824,6 +1809,240 @@ utils.freezeMethods(AxiosHeaders);
|
|||||||
|
|
||||||
var AxiosHeaders$1 = AxiosHeaders;
|
var AxiosHeaders$1 = AxiosHeaders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the data for a request or a response
|
||||||
|
*
|
||||||
|
* @param {Array|Function} fns A single function or Array of functions
|
||||||
|
* @param {?Object} response The response object
|
||||||
|
*
|
||||||
|
* @returns {*} The resulting transformed data
|
||||||
|
*/
|
||||||
|
function transformData(fns, response) {
|
||||||
|
const config = this || defaults$1;
|
||||||
|
const context = response || config;
|
||||||
|
const headers = AxiosHeaders$1.from(context.headers);
|
||||||
|
let data = context.data;
|
||||||
|
|
||||||
|
utils.forEach(fns, function transform(fn) {
|
||||||
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
headers.normalize();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCancel(value) {
|
||||||
|
return !!(value && value.__CANCEL__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
||||||
|
*
|
||||||
|
* @param {string=} message The message.
|
||||||
|
* @param {Object=} config The config.
|
||||||
|
* @param {Object=} request The request.
|
||||||
|
*
|
||||||
|
* @returns {CanceledError} The created error.
|
||||||
|
*/
|
||||||
|
function CanceledError(message, config, request) {
|
||||||
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||||
|
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
||||||
|
this.name = 'CanceledError';
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.inherits(CanceledError, AxiosError, {
|
||||||
|
__CANCEL__: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line strict
|
||||||
|
var httpAdapter = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve or reject a Promise based on response status.
|
||||||
|
*
|
||||||
|
* @param {Function} resolve A function that resolves the promise.
|
||||||
|
* @param {Function} reject A function that rejects the promise.
|
||||||
|
* @param {object} response The response.
|
||||||
|
*
|
||||||
|
* @returns {object} The response.
|
||||||
|
*/
|
||||||
|
function settle(resolve, reject, response) {
|
||||||
|
const validateStatus = response.config.validateStatus;
|
||||||
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||||||
|
resolve(response);
|
||||||
|
} else {
|
||||||
|
reject(new AxiosError(
|
||||||
|
'Request failed with status code ' + response.status,
|
||||||
|
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
||||||
|
response.config,
|
||||||
|
response.request,
|
||||||
|
response
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var cookies = platform.isStandardBrowserEnv ?
|
||||||
|
|
||||||
|
// Standard browser envs support document.cookie
|
||||||
|
(function standardBrowserEnv() {
|
||||||
|
return {
|
||||||
|
write: function write(name, value, expires, path, domain, secure) {
|
||||||
|
const cookie = [];
|
||||||
|
cookie.push(name + '=' + encodeURIComponent(value));
|
||||||
|
|
||||||
|
if (utils.isNumber(expires)) {
|
||||||
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utils.isString(path)) {
|
||||||
|
cookie.push('path=' + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utils.isString(domain)) {
|
||||||
|
cookie.push('domain=' + domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secure === true) {
|
||||||
|
cookie.push('secure');
|
||||||
|
}
|
||||||
|
|
||||||
|
document.cookie = cookie.join('; ');
|
||||||
|
},
|
||||||
|
|
||||||
|
read: function read(name) {
|
||||||
|
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||||
|
return (match ? decodeURIComponent(match[3]) : null);
|
||||||
|
},
|
||||||
|
|
||||||
|
remove: function remove(name) {
|
||||||
|
this.write(name, '', Date.now() - 86400000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})() :
|
||||||
|
|
||||||
|
// Non standard browser env (web workers, react-native) lack needed support.
|
||||||
|
(function nonStandardBrowserEnv() {
|
||||||
|
return {
|
||||||
|
write: function write() {},
|
||||||
|
read: function read() { return null; },
|
||||||
|
remove: function remove() {}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified URL is absolute
|
||||||
|
*
|
||||||
|
* @param {string} url The URL to test
|
||||||
|
*
|
||||||
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||||||
|
*/
|
||||||
|
function isAbsoluteURL(url) {
|
||||||
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||||||
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||||||
|
// by any combination of letters, digits, plus, period, or hyphen.
|
||||||
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the specified URLs
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} relativeURL The relative URL
|
||||||
|
*
|
||||||
|
* @returns {string} The combined URL
|
||||||
|
*/
|
||||||
|
function combineURLs(baseURL, relativeURL) {
|
||||||
|
return relativeURL
|
||||||
|
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
||||||
|
: baseURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
||||||
|
* only when the requestedURL is not already an absolute URL.
|
||||||
|
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} requestedURL Absolute or relative URL to combine
|
||||||
|
*
|
||||||
|
* @returns {string} The combined full path
|
||||||
|
*/
|
||||||
|
function buildFullPath(baseURL, requestedURL) {
|
||||||
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||||||
|
return combineURLs(baseURL, requestedURL);
|
||||||
|
}
|
||||||
|
return requestedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
var isURLSameOrigin = platform.isStandardBrowserEnv ?
|
||||||
|
|
||||||
|
// Standard browser envs have full support of the APIs needed to test
|
||||||
|
// whether the request URL is of the same origin as current location.
|
||||||
|
(function standardBrowserEnv() {
|
||||||
|
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||||
|
const urlParsingNode = document.createElement('a');
|
||||||
|
let originURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a URL to discover it's components
|
||||||
|
*
|
||||||
|
* @param {String} url The URL to be parsed
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
function resolveURL(url) {
|
||||||
|
let href = url;
|
||||||
|
|
||||||
|
if (msie) {
|
||||||
|
// IE needs attribute set twice to normalize properties
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
href = urlParsingNode.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
|
||||||
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||||
|
return {
|
||||||
|
href: urlParsingNode.href,
|
||||||
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||||
|
host: urlParsingNode.host,
|
||||||
|
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||||
|
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||||
|
hostname: urlParsingNode.hostname,
|
||||||
|
port: urlParsingNode.port,
|
||||||
|
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
||||||
|
urlParsingNode.pathname :
|
||||||
|
'/' + urlParsingNode.pathname
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
originURL = resolveURL(window.location.href);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a URL shares the same origin as the current location
|
||||||
|
*
|
||||||
|
* @param {String} requestURL The URL to test
|
||||||
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||||
|
*/
|
||||||
|
return function isURLSameOrigin(requestURL) {
|
||||||
|
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
||||||
|
return (parsed.protocol === originURL.protocol &&
|
||||||
|
parsed.host === originURL.host);
|
||||||
|
};
|
||||||
|
})() :
|
||||||
|
|
||||||
|
// Non standard browser envs (web workers, react-native) lack needed support.
|
||||||
|
(function nonStandardBrowserEnv() {
|
||||||
|
return function isURLSameOrigin() {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
function parseProtocol(url) {
|
||||||
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||||
|
return match && match[1] || '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate data maxRate
|
* Calculate data maxRate
|
||||||
* @param {Number} [samplesCount= 10]
|
* @param {Number} [samplesCount= 10]
|
||||||
@@ -1905,7 +2124,9 @@ function progressEventReducer(listener, isDownloadStream) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function xhrAdapter(config) {
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||||
|
|
||||||
|
var xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||||
let requestData = config.data;
|
let requestData = config.data;
|
||||||
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
||||||
@@ -2106,240 +2327,63 @@ function xhrAdapter(config) {
|
|||||||
// Send the request
|
// Send the request
|
||||||
request.send(requestData || null);
|
request.send(requestData || null);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const adapters = {
|
const knownAdapters = {
|
||||||
http: xhrAdapter,
|
http: httpAdapter,
|
||||||
xhr: xhrAdapter
|
xhr: xhrAdapter
|
||||||
};
|
};
|
||||||
|
|
||||||
var adapters$1 = {
|
utils.forEach(knownAdapters, (fn, value) => {
|
||||||
getAdapter: (nameOrAdapter) => {
|
if(fn) {
|
||||||
if(utils.isString(nameOrAdapter)){
|
try {
|
||||||
const adapter = adapters[nameOrAdapter];
|
Object.defineProperty(fn, 'name', {value});
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
}
|
||||||
|
Object.defineProperty(fn, 'adapterName', {value});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (!nameOrAdapter) {
|
var adapters = {
|
||||||
throw Error(
|
getAdapter: (adapters) => {
|
||||||
utils.hasOwnProp(nameOrAdapter) ?
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||||
`Adapter '${nameOrAdapter}' is not available in the build` :
|
|
||||||
`Can not resolve adapter '${nameOrAdapter}'`
|
const {length} = adapters;
|
||||||
|
let nameOrAdapter;
|
||||||
|
let adapter;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
nameOrAdapter = adapters[i];
|
||||||
|
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!adapter) {
|
||||||
|
if (adapter === false) {
|
||||||
|
throw new AxiosError(
|
||||||
|
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
||||||
|
'ERR_NOT_SUPPORT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return adapter
|
throw new Error(
|
||||||
|
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
||||||
|
`Adapter '${nameOrAdapter}' is not available in the build` :
|
||||||
|
`Unknown adapter '${nameOrAdapter}'`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!utils.isFunction(nameOrAdapter)) {
|
if (!utils.isFunction(adapter)) {
|
||||||
throw new TypeError('adapter is not a function');
|
throw new TypeError('adapter is not a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
return nameOrAdapter;
|
return adapter;
|
||||||
},
|
},
|
||||||
adapters
|
adapters: knownAdapters
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_CONTENT_TYPE = {
|
|
||||||
'Content-Type': undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
|
||||||
* adapter
|
|
||||||
*
|
|
||||||
* @returns {Function}
|
|
||||||
*/
|
|
||||||
function getDefaultAdapter() {
|
|
||||||
let adapter;
|
|
||||||
if (typeof XMLHttpRequest !== 'undefined') {
|
|
||||||
// For browsers use XHR adapter
|
|
||||||
adapter = adapters$1.getAdapter('xhr');
|
|
||||||
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
|
||||||
// For node use HTTP adapter
|
|
||||||
adapter = adapters$1.getAdapter('http');
|
|
||||||
}
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
||||||
* of the input
|
|
||||||
*
|
|
||||||
* @param {any} rawValue - The value to be stringified.
|
|
||||||
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
||||||
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
||||||
*
|
|
||||||
* @returns {string} A stringified version of the rawValue.
|
|
||||||
*/
|
|
||||||
function stringifySafely(rawValue, parser, encoder) {
|
|
||||||
if (utils.isString(rawValue)) {
|
|
||||||
try {
|
|
||||||
(parser || JSON.parse)(rawValue);
|
|
||||||
return utils.trim(rawValue);
|
|
||||||
} catch (e) {
|
|
||||||
if (e.name !== 'SyntaxError') {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (encoder || JSON.stringify)(rawValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaults = {
|
|
||||||
|
|
||||||
transitional: transitionalDefaults,
|
|
||||||
|
|
||||||
adapter: getDefaultAdapter(),
|
|
||||||
|
|
||||||
transformRequest: [function transformRequest(data, headers) {
|
|
||||||
const contentType = headers.getContentType() || '';
|
|
||||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
||||||
const isObjectPayload = utils.isObject(data);
|
|
||||||
|
|
||||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
||||||
data = new FormData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFormData = utils.isFormData(data);
|
|
||||||
|
|
||||||
if (isFormData) {
|
|
||||||
if (!hasJSONContentType) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isArrayBuffer(data) ||
|
|
||||||
utils.isBuffer(data) ||
|
|
||||||
utils.isStream(data) ||
|
|
||||||
utils.isFile(data) ||
|
|
||||||
utils.isBlob(data)
|
|
||||||
) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
if (utils.isArrayBufferView(data)) {
|
|
||||||
return data.buffer;
|
|
||||||
}
|
|
||||||
if (utils.isURLSearchParams(data)) {
|
|
||||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
||||||
return data.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
let isFileList;
|
|
||||||
|
|
||||||
if (isObjectPayload) {
|
|
||||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
||||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
||||||
const _FormData = this.env && this.env.FormData;
|
|
||||||
|
|
||||||
return toFormData(
|
|
||||||
isFileList ? {'files[]': data} : data,
|
|
||||||
_FormData && new _FormData(),
|
|
||||||
this.formSerializer
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isObjectPayload || hasJSONContentType ) {
|
|
||||||
headers.setContentType('application/json', false);
|
|
||||||
return stringifySafely(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
|
|
||||||
transformResponse: [function transformResponse(data) {
|
|
||||||
const transitional = this.transitional || defaults.transitional;
|
|
||||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
||||||
const JSONRequested = this.responseType === 'json';
|
|
||||||
|
|
||||||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
||||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
||||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return JSON.parse(data);
|
|
||||||
} catch (e) {
|
|
||||||
if (strictJSONParsing) {
|
|
||||||
if (e.name === 'SyntaxError') {
|
|
||||||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
||||||
* timeout is not created.
|
|
||||||
*/
|
|
||||||
timeout: 0,
|
|
||||||
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
|
||||||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
||||||
|
|
||||||
maxContentLength: -1,
|
|
||||||
maxBodyLength: -1,
|
|
||||||
|
|
||||||
env: {
|
|
||||||
FormData: platform.classes.FormData,
|
|
||||||
Blob: platform.classes.Blob
|
|
||||||
},
|
|
||||||
|
|
||||||
validateStatus: function validateStatus(status) {
|
|
||||||
return status >= 200 && status < 300;
|
|
||||||
},
|
|
||||||
|
|
||||||
headers: {
|
|
||||||
common: {
|
|
||||||
'Accept': 'application/json, text/plain, */*'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
||||||
defaults.headers[method] = {};
|
|
||||||
});
|
|
||||||
|
|
||||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
||||||
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
||||||
});
|
|
||||||
|
|
||||||
var defaults$1 = defaults;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the data for a request or a response
|
|
||||||
*
|
|
||||||
* @param {Array|Function} fns A single function or Array of functions
|
|
||||||
* @param {?Object} response The response object
|
|
||||||
*
|
|
||||||
* @returns {*} The resulting transformed data
|
|
||||||
*/
|
|
||||||
function transformData(fns, response) {
|
|
||||||
const config = this || defaults$1;
|
|
||||||
const context = response || config;
|
|
||||||
const headers = AxiosHeaders$1.from(context.headers);
|
|
||||||
let data = context.data;
|
|
||||||
|
|
||||||
utils.forEach(fns, function transform(fn) {
|
|
||||||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
headers.normalize();
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCancel(value) {
|
|
||||||
return !!(value && value.__CANCEL__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws a `CanceledError` if cancellation has been requested.
|
* Throws a `CanceledError` if cancellation has been requested.
|
||||||
*
|
*
|
||||||
@@ -2379,7 +2423,7 @@ function dispatchRequest(config) {
|
|||||||
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = config.adapter || defaults$1.adapter;
|
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
||||||
|
|
||||||
return adapter(config).then(function onAdapterResolution(response) {
|
return adapter(config).then(function onAdapterResolution(response) {
|
||||||
throwIfCancellationRequested(config);
|
throwIfCancellationRequested(config);
|
||||||
@@ -2514,7 +2558,7 @@ function mergeConfig(config1, config2) {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION = "1.2.0-alpha.1";
|
const VERSION = "1.2.0";
|
||||||
|
|
||||||
const validators$1 = {};
|
const validators$1 = {};
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+451
-407
@@ -1,4 +1,4 @@
|
|||||||
// Axios v1.2.0-alpha.1 Copyright (c) 2022 Matt Zabriskie and contributors
|
// Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
|
||||||
function bind(fn, thisArg) {
|
function bind(fn, thisArg) {
|
||||||
return function wrap() {
|
return function wrap() {
|
||||||
return fn.apply(thisArg, arguments);
|
return fn.apply(thisArg, arguments);
|
||||||
@@ -595,6 +595,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|||||||
return Number.isFinite(value) ? value : defaultValue;
|
return Number.isFinite(value) ? value : defaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toJSONObject = (obj) => {
|
||||||
|
const stack = new Array(10);
|
||||||
|
|
||||||
|
const visit = (source, i) => {
|
||||||
|
|
||||||
|
if (isObject(source)) {
|
||||||
|
if (stack.indexOf(source) >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!('toJSON' in source)) {
|
||||||
|
stack[i] = source;
|
||||||
|
const target = isArray(source) ? [] : {};
|
||||||
|
|
||||||
|
forEach(source, (value, key) => {
|
||||||
|
const reducedValue = visit(value, i + 1);
|
||||||
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
stack[i] = undefined;
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
};
|
||||||
|
|
||||||
|
return visit(obj, 0);
|
||||||
|
};
|
||||||
|
|
||||||
const utils = {
|
const utils = {
|
||||||
isArray,
|
isArray,
|
||||||
isArrayBuffer,
|
isArrayBuffer,
|
||||||
@@ -640,7 +671,8 @@ const utils = {
|
|||||||
toFiniteNumber,
|
toFiniteNumber,
|
||||||
findKey,
|
findKey,
|
||||||
global: _global,
|
global: _global,
|
||||||
isContextDefined
|
isContextDefined,
|
||||||
|
toJSONObject
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -686,7 +718,7 @@ utils.inherits(AxiosError$1, Error, {
|
|||||||
columnNumber: this.columnNumber,
|
columnNumber: this.columnNumber,
|
||||||
stack: this.stack,
|
stack: this.stack,
|
||||||
// Axios
|
// Axios
|
||||||
config: this.config,
|
config: utils.toJSONObject(this.config),
|
||||||
code: this.code,
|
code: this.code,
|
||||||
status: this.response && this.response.status ? this.response.status : null
|
status: this.response && this.response.status ? this.response.status : null
|
||||||
};
|
};
|
||||||
@@ -1296,209 +1328,162 @@ function formDataToJSON(formData) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_CONTENT_TYPE = {
|
||||||
|
'Content-Type': undefined
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolve or reject a Promise based on response status.
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
||||||
|
* of the input
|
||||||
*
|
*
|
||||||
* @param {Function} resolve A function that resolves the promise.
|
* @param {any} rawValue - The value to be stringified.
|
||||||
* @param {Function} reject A function that rejects the promise.
|
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
||||||
* @param {object} response The response.
|
* @param {Function} encoder - A function that takes a value and returns a string.
|
||||||
*
|
*
|
||||||
* @returns {object} The response.
|
* @returns {string} A stringified version of the rawValue.
|
||||||
*/
|
*/
|
||||||
function settle(resolve, reject, response) {
|
function stringifySafely(rawValue, parser, encoder) {
|
||||||
const validateStatus = response.config.validateStatus;
|
if (utils.isString(rawValue)) {
|
||||||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
try {
|
||||||
resolve(response);
|
(parser || JSON.parse)(rawValue);
|
||||||
} else {
|
return utils.trim(rawValue);
|
||||||
reject(new AxiosError$1(
|
} catch (e) {
|
||||||
'Request failed with status code ' + response.status,
|
if (e.name !== 'SyntaxError') {
|
||||||
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
throw e;
|
||||||
response.config,
|
|
||||||
response.request,
|
|
||||||
response
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const cookies = platform.isStandardBrowserEnv ?
|
|
||||||
|
|
||||||
// Standard browser envs support document.cookie
|
|
||||||
(function standardBrowserEnv() {
|
|
||||||
return {
|
|
||||||
write: function write(name, value, expires, path, domain, secure) {
|
|
||||||
const cookie = [];
|
|
||||||
cookie.push(name + '=' + encodeURIComponent(value));
|
|
||||||
|
|
||||||
if (utils.isNumber(expires)) {
|
|
||||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isString(path)) {
|
|
||||||
cookie.push('path=' + path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isString(domain)) {
|
|
||||||
cookie.push('domain=' + domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (secure === true) {
|
|
||||||
cookie.push('secure');
|
|
||||||
}
|
|
||||||
|
|
||||||
document.cookie = cookie.join('; ');
|
|
||||||
},
|
|
||||||
|
|
||||||
read: function read(name) {
|
|
||||||
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
|
||||||
return (match ? decodeURIComponent(match[3]) : null);
|
|
||||||
},
|
|
||||||
|
|
||||||
remove: function remove(name) {
|
|
||||||
this.write(name, '', Date.now() - 86400000);
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
})() :
|
|
||||||
|
|
||||||
// Non standard browser env (web workers, react-native) lack needed support.
|
|
||||||
(function nonStandardBrowserEnv() {
|
|
||||||
return {
|
|
||||||
write: function write() {},
|
|
||||||
read: function read() { return null; },
|
|
||||||
remove: function remove() {}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the specified URL is absolute
|
|
||||||
*
|
|
||||||
* @param {string} url The URL to test
|
|
||||||
*
|
|
||||||
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
|
||||||
*/
|
|
||||||
function isAbsoluteURL(url) {
|
|
||||||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
|
||||||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
|
||||||
// by any combination of letters, digits, plus, period, or hyphen.
|
|
||||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the specified URLs
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} relativeURL The relative URL
|
|
||||||
*
|
|
||||||
* @returns {string} The combined URL
|
|
||||||
*/
|
|
||||||
function combineURLs(baseURL, relativeURL) {
|
|
||||||
return relativeURL
|
|
||||||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
||||||
: baseURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
||||||
* only when the requestedURL is not already an absolute URL.
|
|
||||||
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} requestedURL Absolute or relative URL to combine
|
|
||||||
*
|
|
||||||
* @returns {string} The combined full path
|
|
||||||
*/
|
|
||||||
function buildFullPath(baseURL, requestedURL) {
|
|
||||||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
||||||
return combineURLs(baseURL, requestedURL);
|
|
||||||
}
|
}
|
||||||
return requestedURL;
|
|
||||||
|
return (encoder || JSON.stringify)(rawValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isURLSameOrigin = platform.isStandardBrowserEnv ?
|
const defaults = {
|
||||||
|
|
||||||
// Standard browser envs have full support of the APIs needed to test
|
transitional: transitionalDefaults,
|
||||||
// whether the request URL is of the same origin as current location.
|
|
||||||
(function standardBrowserEnv() {
|
|
||||||
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
|
||||||
const urlParsingNode = document.createElement('a');
|
|
||||||
let originURL;
|
|
||||||
|
|
||||||
/**
|
adapter: ['xhr', 'http'],
|
||||||
* Parse a URL to discover it's components
|
|
||||||
*
|
|
||||||
* @param {String} url The URL to be parsed
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
function resolveURL(url) {
|
|
||||||
let href = url;
|
|
||||||
|
|
||||||
if (msie) {
|
transformRequest: [function transformRequest(data, headers) {
|
||||||
// IE needs attribute set twice to normalize properties
|
const contentType = headers.getContentType() || '';
|
||||||
urlParsingNode.setAttribute('href', href);
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||||
href = urlParsingNode.href;
|
const isObjectPayload = utils.isObject(data);
|
||||||
}
|
|
||||||
|
|
||||||
urlParsingNode.setAttribute('href', href);
|
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||||
|
data = new FormData(data);
|
||||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
|
||||||
return {
|
|
||||||
href: urlParsingNode.href,
|
|
||||||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
|
||||||
host: urlParsingNode.host,
|
|
||||||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
|
||||||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
|
||||||
hostname: urlParsingNode.hostname,
|
|
||||||
port: urlParsingNode.port,
|
|
||||||
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
|
||||||
urlParsingNode.pathname :
|
|
||||||
'/' + urlParsingNode.pathname
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
originURL = resolveURL(window.location.href);
|
const isFormData = utils.isFormData(data);
|
||||||
|
|
||||||
/**
|
if (isFormData) {
|
||||||
* Determine if a URL shares the same origin as the current location
|
if (!hasJSONContentType) {
|
||||||
*
|
return data;
|
||||||
* @param {String} requestURL The URL to test
|
}
|
||||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||||
*/
|
}
|
||||||
return function isURLSameOrigin(requestURL) {
|
|
||||||
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
||||||
return (parsed.protocol === originURL.protocol &&
|
|
||||||
parsed.host === originURL.host);
|
|
||||||
};
|
|
||||||
})() :
|
|
||||||
|
|
||||||
// Non standard browser envs (web workers, react-native) lack needed support.
|
if (utils.isArrayBuffer(data) ||
|
||||||
(function nonStandardBrowserEnv() {
|
utils.isBuffer(data) ||
|
||||||
return function isURLSameOrigin() {
|
utils.isStream(data) ||
|
||||||
return true;
|
utils.isFile(data) ||
|
||||||
};
|
utils.isBlob(data)
|
||||||
})();
|
) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
if (utils.isArrayBufferView(data)) {
|
||||||
|
return data.buffer;
|
||||||
|
}
|
||||||
|
if (utils.isURLSearchParams(data)) {
|
||||||
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
let isFileList;
|
||||||
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
||||||
*
|
|
||||||
* @param {string=} message The message.
|
|
||||||
* @param {Object=} config The config.
|
|
||||||
* @param {Object=} request The request.
|
|
||||||
*
|
|
||||||
* @returns {CanceledError} The created error.
|
|
||||||
*/
|
|
||||||
function CanceledError$1(message, config, request) {
|
|
||||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
||||||
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
||||||
this.name = 'CanceledError';
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.inherits(CanceledError$1, AxiosError$1, {
|
if (isObjectPayload) {
|
||||||
__CANCEL__: true
|
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||||
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||||
|
const _FormData = this.env && this.env.FormData;
|
||||||
|
|
||||||
|
return toFormData$1(
|
||||||
|
isFileList ? {'files[]': data} : data,
|
||||||
|
_FormData && new _FormData(),
|
||||||
|
this.formSerializer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isObjectPayload || hasJSONContentType ) {
|
||||||
|
headers.setContentType('application/json', false);
|
||||||
|
return stringifySafely(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
|
||||||
|
transformResponse: [function transformResponse(data) {
|
||||||
|
const transitional = this.transitional || defaults.transitional;
|
||||||
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||||
|
const JSONRequested = this.responseType === 'json';
|
||||||
|
|
||||||
|
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||||
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||||
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
if (strictJSONParsing) {
|
||||||
|
if (e.name === 'SyntaxError') {
|
||||||
|
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||||
|
* timeout is not created.
|
||||||
|
*/
|
||||||
|
timeout: 0,
|
||||||
|
|
||||||
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||||||
|
|
||||||
|
maxContentLength: -1,
|
||||||
|
maxBodyLength: -1,
|
||||||
|
|
||||||
|
env: {
|
||||||
|
FormData: platform.classes.FormData,
|
||||||
|
Blob: platform.classes.Blob
|
||||||
|
},
|
||||||
|
|
||||||
|
validateStatus: function validateStatus(status) {
|
||||||
|
return status >= 200 && status < 300;
|
||||||
|
},
|
||||||
|
|
||||||
|
headers: {
|
||||||
|
common: {
|
||||||
|
'Accept': 'application/json, text/plain, */*'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||||||
|
defaults.headers[method] = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
function parseProtocol(url) {
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||||||
return match && match[1] || '';
|
});
|
||||||
}
|
|
||||||
|
const defaults$1 = defaults;
|
||||||
|
|
||||||
// RawAxiosHeaders whose duplicates are ignored by node
|
// RawAxiosHeaders whose duplicates are ignored by node
|
||||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||||
@@ -1822,6 +1807,240 @@ utils.freezeMethods(AxiosHeaders$1);
|
|||||||
|
|
||||||
const AxiosHeaders$2 = AxiosHeaders$1;
|
const AxiosHeaders$2 = AxiosHeaders$1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the data for a request or a response
|
||||||
|
*
|
||||||
|
* @param {Array|Function} fns A single function or Array of functions
|
||||||
|
* @param {?Object} response The response object
|
||||||
|
*
|
||||||
|
* @returns {*} The resulting transformed data
|
||||||
|
*/
|
||||||
|
function transformData(fns, response) {
|
||||||
|
const config = this || defaults$1;
|
||||||
|
const context = response || config;
|
||||||
|
const headers = AxiosHeaders$2.from(context.headers);
|
||||||
|
let data = context.data;
|
||||||
|
|
||||||
|
utils.forEach(fns, function transform(fn) {
|
||||||
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
headers.normalize();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCancel$1(value) {
|
||||||
|
return !!(value && value.__CANCEL__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
||||||
|
*
|
||||||
|
* @param {string=} message The message.
|
||||||
|
* @param {Object=} config The config.
|
||||||
|
* @param {Object=} request The request.
|
||||||
|
*
|
||||||
|
* @returns {CanceledError} The created error.
|
||||||
|
*/
|
||||||
|
function CanceledError$1(message, config, request) {
|
||||||
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||||
|
AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
|
||||||
|
this.name = 'CanceledError';
|
||||||
|
}
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @param {Function} resolve A function that resolves the promise.
|
||||||
|
* @param {Function} reject A function that rejects the promise.
|
||||||
|
* @param {object} response The response.
|
||||||
|
*
|
||||||
|
* @returns {object} The response.
|
||||||
|
*/
|
||||||
|
function settle(resolve, reject, response) {
|
||||||
|
const validateStatus = response.config.validateStatus;
|
||||||
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||||||
|
resolve(response);
|
||||||
|
} else {
|
||||||
|
reject(new AxiosError$1(
|
||||||
|
'Request failed with status code ' + response.status,
|
||||||
|
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
||||||
|
response.config,
|
||||||
|
response.request,
|
||||||
|
response
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const cookies = platform.isStandardBrowserEnv ?
|
||||||
|
|
||||||
|
// Standard browser envs support document.cookie
|
||||||
|
(function standardBrowserEnv() {
|
||||||
|
return {
|
||||||
|
write: function write(name, value, expires, path, domain, secure) {
|
||||||
|
const cookie = [];
|
||||||
|
cookie.push(name + '=' + encodeURIComponent(value));
|
||||||
|
|
||||||
|
if (utils.isNumber(expires)) {
|
||||||
|
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utils.isString(path)) {
|
||||||
|
cookie.push('path=' + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utils.isString(domain)) {
|
||||||
|
cookie.push('domain=' + domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (secure === true) {
|
||||||
|
cookie.push('secure');
|
||||||
|
}
|
||||||
|
|
||||||
|
document.cookie = cookie.join('; ');
|
||||||
|
},
|
||||||
|
|
||||||
|
read: function read(name) {
|
||||||
|
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||||
|
return (match ? decodeURIComponent(match[3]) : null);
|
||||||
|
},
|
||||||
|
|
||||||
|
remove: function remove(name) {
|
||||||
|
this.write(name, '', Date.now() - 86400000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})() :
|
||||||
|
|
||||||
|
// Non standard browser env (web workers, react-native) lack needed support.
|
||||||
|
(function nonStandardBrowserEnv() {
|
||||||
|
return {
|
||||||
|
write: function write() {},
|
||||||
|
read: function read() { return null; },
|
||||||
|
remove: function remove() {}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified URL is absolute
|
||||||
|
*
|
||||||
|
* @param {string} url The URL to test
|
||||||
|
*
|
||||||
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||||||
|
*/
|
||||||
|
function isAbsoluteURL(url) {
|
||||||
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||||||
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||||||
|
// by any combination of letters, digits, plus, period, or hyphen.
|
||||||
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the specified URLs
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} relativeURL The relative URL
|
||||||
|
*
|
||||||
|
* @returns {string} The combined URL
|
||||||
|
*/
|
||||||
|
function combineURLs(baseURL, relativeURL) {
|
||||||
|
return relativeURL
|
||||||
|
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
||||||
|
: baseURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
||||||
|
* only when the requestedURL is not already an absolute URL.
|
||||||
|
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} requestedURL Absolute or relative URL to combine
|
||||||
|
*
|
||||||
|
* @returns {string} The combined full path
|
||||||
|
*/
|
||||||
|
function buildFullPath(baseURL, requestedURL) {
|
||||||
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||||||
|
return combineURLs(baseURL, requestedURL);
|
||||||
|
}
|
||||||
|
return requestedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isURLSameOrigin = platform.isStandardBrowserEnv ?
|
||||||
|
|
||||||
|
// Standard browser envs have full support of the APIs needed to test
|
||||||
|
// whether the request URL is of the same origin as current location.
|
||||||
|
(function standardBrowserEnv() {
|
||||||
|
const msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||||
|
const urlParsingNode = document.createElement('a');
|
||||||
|
let originURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a URL to discover it's components
|
||||||
|
*
|
||||||
|
* @param {String} url The URL to be parsed
|
||||||
|
* @returns {Object}
|
||||||
|
*/
|
||||||
|
function resolveURL(url) {
|
||||||
|
let href = url;
|
||||||
|
|
||||||
|
if (msie) {
|
||||||
|
// IE needs attribute set twice to normalize properties
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
href = urlParsingNode.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
|
||||||
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||||
|
return {
|
||||||
|
href: urlParsingNode.href,
|
||||||
|
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||||
|
host: urlParsingNode.host,
|
||||||
|
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||||
|
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||||
|
hostname: urlParsingNode.hostname,
|
||||||
|
port: urlParsingNode.port,
|
||||||
|
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
||||||
|
urlParsingNode.pathname :
|
||||||
|
'/' + urlParsingNode.pathname
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
originURL = resolveURL(window.location.href);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a URL shares the same origin as the current location
|
||||||
|
*
|
||||||
|
* @param {String} requestURL The URL to test
|
||||||
|
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||||
|
*/
|
||||||
|
return function isURLSameOrigin(requestURL) {
|
||||||
|
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
||||||
|
return (parsed.protocol === originURL.protocol &&
|
||||||
|
parsed.host === originURL.host);
|
||||||
|
};
|
||||||
|
})() :
|
||||||
|
|
||||||
|
// Non standard browser envs (web workers, react-native) lack needed support.
|
||||||
|
(function nonStandardBrowserEnv() {
|
||||||
|
return function isURLSameOrigin() {
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
function parseProtocol(url) {
|
||||||
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||||
|
return match && match[1] || '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate data maxRate
|
* Calculate data maxRate
|
||||||
* @param {Number} [samplesCount= 10]
|
* @param {Number} [samplesCount= 10]
|
||||||
@@ -1903,7 +2122,9 @@ function progressEventReducer(listener, isDownloadStream) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function xhrAdapter(config) {
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||||
|
|
||||||
|
const xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||||
let requestData = config.data;
|
let requestData = config.data;
|
||||||
const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
|
const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
|
||||||
@@ -2104,240 +2325,63 @@ function xhrAdapter(config) {
|
|||||||
// Send the request
|
// Send the request
|
||||||
request.send(requestData || null);
|
request.send(requestData || null);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const adapters = {
|
const knownAdapters = {
|
||||||
http: xhrAdapter,
|
http: httpAdapter,
|
||||||
xhr: xhrAdapter
|
xhr: xhrAdapter
|
||||||
};
|
};
|
||||||
|
|
||||||
const adapters$1 = {
|
utils.forEach(knownAdapters, (fn, value) => {
|
||||||
getAdapter: (nameOrAdapter) => {
|
if(fn) {
|
||||||
if(utils.isString(nameOrAdapter)){
|
try {
|
||||||
const adapter = adapters[nameOrAdapter];
|
Object.defineProperty(fn, 'name', {value});
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
}
|
||||||
|
Object.defineProperty(fn, 'adapterName', {value});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (!nameOrAdapter) {
|
const adapters = {
|
||||||
throw Error(
|
getAdapter: (adapters) => {
|
||||||
utils.hasOwnProp(nameOrAdapter) ?
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||||
`Adapter '${nameOrAdapter}' is not available in the build` :
|
|
||||||
`Can not resolve adapter '${nameOrAdapter}'`
|
const {length} = adapters;
|
||||||
|
let nameOrAdapter;
|
||||||
|
let adapter;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
nameOrAdapter = adapters[i];
|
||||||
|
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!adapter) {
|
||||||
|
if (adapter === false) {
|
||||||
|
throw new AxiosError$1(
|
||||||
|
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
||||||
|
'ERR_NOT_SUPPORT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return adapter
|
throw new Error(
|
||||||
|
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
||||||
|
`Adapter '${nameOrAdapter}' is not available in the build` :
|
||||||
|
`Unknown adapter '${nameOrAdapter}'`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!utils.isFunction(nameOrAdapter)) {
|
if (!utils.isFunction(adapter)) {
|
||||||
throw new TypeError('adapter is not a function');
|
throw new TypeError('adapter is not a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
return nameOrAdapter;
|
return adapter;
|
||||||
},
|
},
|
||||||
adapters
|
adapters: knownAdapters
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_CONTENT_TYPE = {
|
|
||||||
'Content-Type': undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
|
||||||
* adapter
|
|
||||||
*
|
|
||||||
* @returns {Function}
|
|
||||||
*/
|
|
||||||
function getDefaultAdapter() {
|
|
||||||
let adapter;
|
|
||||||
if (typeof XMLHttpRequest !== 'undefined') {
|
|
||||||
// For browsers use XHR adapter
|
|
||||||
adapter = adapters$1.getAdapter('xhr');
|
|
||||||
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
|
||||||
// For node use HTTP adapter
|
|
||||||
adapter = adapters$1.getAdapter('http');
|
|
||||||
}
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
||||||
* of the input
|
|
||||||
*
|
|
||||||
* @param {any} rawValue - The value to be stringified.
|
|
||||||
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
||||||
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
||||||
*
|
|
||||||
* @returns {string} A stringified version of the rawValue.
|
|
||||||
*/
|
|
||||||
function stringifySafely(rawValue, parser, encoder) {
|
|
||||||
if (utils.isString(rawValue)) {
|
|
||||||
try {
|
|
||||||
(parser || JSON.parse)(rawValue);
|
|
||||||
return utils.trim(rawValue);
|
|
||||||
} catch (e) {
|
|
||||||
if (e.name !== 'SyntaxError') {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (encoder || JSON.stringify)(rawValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaults = {
|
|
||||||
|
|
||||||
transitional: transitionalDefaults,
|
|
||||||
|
|
||||||
adapter: getDefaultAdapter(),
|
|
||||||
|
|
||||||
transformRequest: [function transformRequest(data, headers) {
|
|
||||||
const contentType = headers.getContentType() || '';
|
|
||||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
||||||
const isObjectPayload = utils.isObject(data);
|
|
||||||
|
|
||||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
||||||
data = new FormData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFormData = utils.isFormData(data);
|
|
||||||
|
|
||||||
if (isFormData) {
|
|
||||||
if (!hasJSONContentType) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isArrayBuffer(data) ||
|
|
||||||
utils.isBuffer(data) ||
|
|
||||||
utils.isStream(data) ||
|
|
||||||
utils.isFile(data) ||
|
|
||||||
utils.isBlob(data)
|
|
||||||
) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
if (utils.isArrayBufferView(data)) {
|
|
||||||
return data.buffer;
|
|
||||||
}
|
|
||||||
if (utils.isURLSearchParams(data)) {
|
|
||||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
||||||
return data.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
let isFileList;
|
|
||||||
|
|
||||||
if (isObjectPayload) {
|
|
||||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
||||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
||||||
const _FormData = this.env && this.env.FormData;
|
|
||||||
|
|
||||||
return toFormData$1(
|
|
||||||
isFileList ? {'files[]': data} : data,
|
|
||||||
_FormData && new _FormData(),
|
|
||||||
this.formSerializer
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isObjectPayload || hasJSONContentType ) {
|
|
||||||
headers.setContentType('application/json', false);
|
|
||||||
return stringifySafely(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
|
|
||||||
transformResponse: [function transformResponse(data) {
|
|
||||||
const transitional = this.transitional || defaults.transitional;
|
|
||||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
||||||
const JSONRequested = this.responseType === 'json';
|
|
||||||
|
|
||||||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
||||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
||||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return JSON.parse(data);
|
|
||||||
} catch (e) {
|
|
||||||
if (strictJSONParsing) {
|
|
||||||
if (e.name === 'SyntaxError') {
|
|
||||||
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
||||||
* timeout is not created.
|
|
||||||
*/
|
|
||||||
timeout: 0,
|
|
||||||
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
|
||||||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
||||||
|
|
||||||
maxContentLength: -1,
|
|
||||||
maxBodyLength: -1,
|
|
||||||
|
|
||||||
env: {
|
|
||||||
FormData: platform.classes.FormData,
|
|
||||||
Blob: platform.classes.Blob
|
|
||||||
},
|
|
||||||
|
|
||||||
validateStatus: function validateStatus(status) {
|
|
||||||
return status >= 200 && status < 300;
|
|
||||||
},
|
|
||||||
|
|
||||||
headers: {
|
|
||||||
common: {
|
|
||||||
'Accept': 'application/json, text/plain, */*'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
||||||
defaults.headers[method] = {};
|
|
||||||
});
|
|
||||||
|
|
||||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
||||||
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaults$1 = defaults;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the data for a request or a response
|
|
||||||
*
|
|
||||||
* @param {Array|Function} fns A single function or Array of functions
|
|
||||||
* @param {?Object} response The response object
|
|
||||||
*
|
|
||||||
* @returns {*} The resulting transformed data
|
|
||||||
*/
|
|
||||||
function transformData(fns, response) {
|
|
||||||
const config = this || defaults$1;
|
|
||||||
const context = response || config;
|
|
||||||
const headers = AxiosHeaders$2.from(context.headers);
|
|
||||||
let data = context.data;
|
|
||||||
|
|
||||||
utils.forEach(fns, function transform(fn) {
|
|
||||||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
headers.normalize();
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCancel$1(value) {
|
|
||||||
return !!(value && value.__CANCEL__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws a `CanceledError` if cancellation has been requested.
|
* Throws a `CanceledError` if cancellation has been requested.
|
||||||
*
|
*
|
||||||
@@ -2377,7 +2421,7 @@ function dispatchRequest(config) {
|
|||||||
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = config.adapter || defaults$1.adapter;
|
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
||||||
|
|
||||||
return adapter(config).then(function onAdapterResolution(response) {
|
return adapter(config).then(function onAdapterResolution(response) {
|
||||||
throwIfCancellationRequested(config);
|
throwIfCancellationRequested(config);
|
||||||
@@ -2512,7 +2556,7 @@ function mergeConfig(config1, config2) {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VERSION$1 = "1.2.0-alpha.1";
|
const VERSION$1 = "1.2.0";
|
||||||
|
|
||||||
const validators$1 = {};
|
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
+410
-367
@@ -1,4 +1,4 @@
|
|||||||
// Axios v1.2.0-alpha.1 Copyright (c) 2022 Matt Zabriskie and contributors
|
// Axios v1.2.0 Copyright (c) 2022 Matt Zabriskie and contributors
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const FormData$1 = require('form-data');
|
const FormData$1 = require('form-data');
|
||||||
@@ -618,6 +618,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|||||||
return Number.isFinite(value) ? value : defaultValue;
|
return Number.isFinite(value) ? value : defaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toJSONObject = (obj) => {
|
||||||
|
const stack = new Array(10);
|
||||||
|
|
||||||
|
const visit = (source, i) => {
|
||||||
|
|
||||||
|
if (isObject(source)) {
|
||||||
|
if (stack.indexOf(source) >= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!('toJSON' in source)) {
|
||||||
|
stack[i] = source;
|
||||||
|
const target = isArray(source) ? [] : {};
|
||||||
|
|
||||||
|
forEach(source, (value, key) => {
|
||||||
|
const reducedValue = visit(value, i + 1);
|
||||||
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
||||||
|
});
|
||||||
|
|
||||||
|
stack[i] = undefined;
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return source;
|
||||||
|
};
|
||||||
|
|
||||||
|
return visit(obj, 0);
|
||||||
|
};
|
||||||
|
|
||||||
const utils = {
|
const utils = {
|
||||||
isArray,
|
isArray,
|
||||||
isArrayBuffer,
|
isArrayBuffer,
|
||||||
@@ -663,7 +694,8 @@ const utils = {
|
|||||||
toFiniteNumber,
|
toFiniteNumber,
|
||||||
findKey,
|
findKey,
|
||||||
global: _global,
|
global: _global,
|
||||||
isContextDefined
|
isContextDefined,
|
||||||
|
toJSONObject
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -709,7 +741,7 @@ utils.inherits(AxiosError, Error, {
|
|||||||
columnNumber: this.columnNumber,
|
columnNumber: this.columnNumber,
|
||||||
stack: this.stack,
|
stack: this.stack,
|
||||||
// Axios
|
// Axios
|
||||||
config: this.config,
|
config: utils.toJSONObject(this.config),
|
||||||
code: this.code,
|
code: this.code,
|
||||||
status: this.response && this.response.status ? this.response.status : null
|
status: this.response && this.response.status ? this.response.status : null
|
||||||
};
|
};
|
||||||
@@ -1281,148 +1313,162 @@ function formDataToJSON(formData) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
const DEFAULT_CONTENT_TYPE = {
|
||||||
* Resolve or reject a Promise based on response status.
|
'Content-Type': undefined
|
||||||
*
|
};
|
||||||
* @param {Function} resolve A function that resolves the promise.
|
|
||||||
* @param {Function} reject A function that rejects the promise.
|
|
||||||
* @param {object} response The response.
|
|
||||||
*
|
|
||||||
* @returns {object} The response.
|
|
||||||
*/
|
|
||||||
function settle(resolve, reject, response) {
|
|
||||||
const validateStatus = response.config.validateStatus;
|
|
||||||
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
|
||||||
resolve(response);
|
|
||||||
} else {
|
|
||||||
reject(new AxiosError(
|
|
||||||
'Request failed with status code ' + response.status,
|
|
||||||
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
||||||
response.config,
|
|
||||||
response.request,
|
|
||||||
response
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the specified URL is absolute
|
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
||||||
|
* of the input
|
||||||
*
|
*
|
||||||
* @param {string} url The URL to test
|
* @param {any} rawValue - The value to be stringified.
|
||||||
|
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
||||||
|
* @param {Function} encoder - A function that takes a value and returns a string.
|
||||||
*
|
*
|
||||||
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
* @returns {string} A stringified version of the rawValue.
|
||||||
*/
|
*/
|
||||||
function isAbsoluteURL(url) {
|
function stringifySafely(rawValue, parser, encoder) {
|
||||||
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
if (utils.isString(rawValue)) {
|
||||||
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
try {
|
||||||
// by any combination of letters, digits, plus, period, or hyphen.
|
(parser || JSON.parse)(rawValue);
|
||||||
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
return utils.trim(rawValue);
|
||||||
}
|
} catch (e) {
|
||||||
|
if (e.name !== 'SyntaxError') {
|
||||||
/**
|
throw e;
|
||||||
* Creates a new URL by combining the specified URLs
|
}
|
||||||
*
|
}
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} relativeURL The relative URL
|
|
||||||
*
|
|
||||||
* @returns {string} The combined URL
|
|
||||||
*/
|
|
||||||
function combineURLs(baseURL, relativeURL) {
|
|
||||||
return relativeURL
|
|
||||||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
|
||||||
: baseURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new URL by combining the baseURL with the requestedURL,
|
|
||||||
* only when the requestedURL is not already an absolute URL.
|
|
||||||
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
|
||||||
*
|
|
||||||
* @param {string} baseURL The base URL
|
|
||||||
* @param {string} requestedURL Absolute or relative URL to combine
|
|
||||||
*
|
|
||||||
* @returns {string} The combined full path
|
|
||||||
*/
|
|
||||||
function buildFullPath(baseURL, requestedURL) {
|
|
||||||
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
|
||||||
return combineURLs(baseURL, requestedURL);
|
|
||||||
}
|
|
||||||
return requestedURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VERSION = "1.2.0-alpha.1";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
|
||||||
*
|
|
||||||
* @param {string=} message The message.
|
|
||||||
* @param {Object=} config The config.
|
|
||||||
* @param {Object=} request The request.
|
|
||||||
*
|
|
||||||
* @returns {CanceledError} The created error.
|
|
||||||
*/
|
|
||||||
function CanceledError(message, config, request) {
|
|
||||||
// eslint-disable-next-line no-eq-null,eqeqeq
|
|
||||||
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
|
||||||
this.name = 'CanceledError';
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.inherits(CanceledError, AxiosError, {
|
|
||||||
__CANCEL__: true
|
|
||||||
});
|
|
||||||
|
|
||||||
function parseProtocol(url) {
|
|
||||||
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
||||||
return match && match[1] || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse data uri to a Buffer or Blob
|
|
||||||
*
|
|
||||||
* @param {String} uri
|
|
||||||
* @param {?Boolean} asBlob
|
|
||||||
* @param {?Object} options
|
|
||||||
* @param {?Function} options.Blob
|
|
||||||
*
|
|
||||||
* @returns {Buffer|Blob}
|
|
||||||
*/
|
|
||||||
function fromDataURI(uri, asBlob, options) {
|
|
||||||
const _Blob = options && options.Blob || platform.classes.Blob;
|
|
||||||
const protocol = parseProtocol(uri);
|
|
||||||
|
|
||||||
if (asBlob === undefined && _Blob) {
|
|
||||||
asBlob = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (protocol === 'data') {
|
return (encoder || JSON.stringify)(rawValue);
|
||||||
uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
|
}
|
||||||
|
|
||||||
const match = DATA_URL_PATTERN.exec(uri);
|
const defaults = {
|
||||||
|
|
||||||
if (!match) {
|
transitional: transitionalDefaults,
|
||||||
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
|
|
||||||
|
adapter: ['xhr', 'http'],
|
||||||
|
|
||||||
|
transformRequest: [function transformRequest(data, headers) {
|
||||||
|
const contentType = headers.getContentType() || '';
|
||||||
|
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
||||||
|
const isObjectPayload = utils.isObject(data);
|
||||||
|
|
||||||
|
if (isObjectPayload && utils.isHTMLForm(data)) {
|
||||||
|
data = new FormData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mime = match[1];
|
const isFormData = utils.isFormData(data);
|
||||||
const isBase64 = match[2];
|
|
||||||
const body = match[3];
|
|
||||||
const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
|
|
||||||
|
|
||||||
if (asBlob) {
|
if (isFormData) {
|
||||||
if (!_Blob) {
|
if (!hasJSONContentType) {
|
||||||
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
return data;
|
||||||
|
}
|
||||||
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utils.isArrayBuffer(data) ||
|
||||||
|
utils.isBuffer(data) ||
|
||||||
|
utils.isStream(data) ||
|
||||||
|
utils.isFile(data) ||
|
||||||
|
utils.isBlob(data)
|
||||||
|
) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
if (utils.isArrayBufferView(data)) {
|
||||||
|
return data.buffer;
|
||||||
|
}
|
||||||
|
if (utils.isURLSearchParams(data)) {
|
||||||
|
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
||||||
|
return data.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
let isFileList;
|
||||||
|
|
||||||
|
if (isObjectPayload) {
|
||||||
|
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
||||||
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new _Blob([buffer], {type: mime});
|
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
||||||
|
const _FormData = this.env && this.env.FormData;
|
||||||
|
|
||||||
|
return toFormData(
|
||||||
|
isFileList ? {'files[]': data} : data,
|
||||||
|
_FormData && new _FormData(),
|
||||||
|
this.formSerializer
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
if (isObjectPayload || hasJSONContentType ) {
|
||||||
}
|
headers.setContentType('application/json', false);
|
||||||
|
return stringifySafely(data);
|
||||||
|
}
|
||||||
|
|
||||||
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
|
return data;
|
||||||
}
|
}],
|
||||||
|
|
||||||
|
transformResponse: [function transformResponse(data) {
|
||||||
|
const transitional = this.transitional || defaults.transitional;
|
||||||
|
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
||||||
|
const JSONRequested = this.responseType === 'json';
|
||||||
|
|
||||||
|
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
||||||
|
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
||||||
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(data);
|
||||||
|
} catch (e) {
|
||||||
|
if (strictJSONParsing) {
|
||||||
|
if (e.name === 'SyntaxError') {
|
||||||
|
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}],
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
||||||
|
* timeout is not created.
|
||||||
|
*/
|
||||||
|
timeout: 0,
|
||||||
|
|
||||||
|
xsrfCookieName: 'XSRF-TOKEN',
|
||||||
|
xsrfHeaderName: 'X-XSRF-TOKEN',
|
||||||
|
|
||||||
|
maxContentLength: -1,
|
||||||
|
maxBodyLength: -1,
|
||||||
|
|
||||||
|
env: {
|
||||||
|
FormData: platform.classes.FormData,
|
||||||
|
Blob: platform.classes.Blob
|
||||||
|
},
|
||||||
|
|
||||||
|
validateStatus: function validateStatus(status) {
|
||||||
|
return status >= 200 && status < 300;
|
||||||
|
},
|
||||||
|
|
||||||
|
headers: {
|
||||||
|
common: {
|
||||||
|
'Accept': 'application/json, text/plain, */*'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
||||||
|
defaults.headers[method] = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
||||||
|
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
||||||
|
});
|
||||||
|
|
||||||
|
const defaults$1 = defaults;
|
||||||
|
|
||||||
// RawAxiosHeaders whose duplicates are ignored by node
|
// RawAxiosHeaders whose duplicates are ignored by node
|
||||||
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
// c.f. https://nodejs.org/api/http.html#http_message_headers
|
||||||
@@ -1746,6 +1792,176 @@ utils.freezeMethods(AxiosHeaders);
|
|||||||
|
|
||||||
const AxiosHeaders$1 = AxiosHeaders;
|
const AxiosHeaders$1 = AxiosHeaders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the data for a request or a response
|
||||||
|
*
|
||||||
|
* @param {Array|Function} fns A single function or Array of functions
|
||||||
|
* @param {?Object} response The response object
|
||||||
|
*
|
||||||
|
* @returns {*} The resulting transformed data
|
||||||
|
*/
|
||||||
|
function transformData(fns, response) {
|
||||||
|
const config = this || defaults$1;
|
||||||
|
const context = response || config;
|
||||||
|
const headers = AxiosHeaders$1.from(context.headers);
|
||||||
|
let data = context.data;
|
||||||
|
|
||||||
|
utils.forEach(fns, function transform(fn) {
|
||||||
|
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
headers.normalize();
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isCancel(value) {
|
||||||
|
return !!(value && value.__CANCEL__);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
||||||
|
*
|
||||||
|
* @param {string=} message The message.
|
||||||
|
* @param {Object=} config The config.
|
||||||
|
* @param {Object=} request The request.
|
||||||
|
*
|
||||||
|
* @returns {CanceledError} The created error.
|
||||||
|
*/
|
||||||
|
function CanceledError(message, config, request) {
|
||||||
|
// eslint-disable-next-line no-eq-null,eqeqeq
|
||||||
|
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
|
||||||
|
this.name = 'CanceledError';
|
||||||
|
}
|
||||||
|
|
||||||
|
utils.inherits(CanceledError, AxiosError, {
|
||||||
|
__CANCEL__: true
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve or reject a Promise based on response status.
|
||||||
|
*
|
||||||
|
* @param {Function} resolve A function that resolves the promise.
|
||||||
|
* @param {Function} reject A function that rejects the promise.
|
||||||
|
* @param {object} response The response.
|
||||||
|
*
|
||||||
|
* @returns {object} The response.
|
||||||
|
*/
|
||||||
|
function settle(resolve, reject, response) {
|
||||||
|
const validateStatus = response.config.validateStatus;
|
||||||
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
||||||
|
resolve(response);
|
||||||
|
} else {
|
||||||
|
reject(new AxiosError(
|
||||||
|
'Request failed with status code ' + response.status,
|
||||||
|
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
||||||
|
response.config,
|
||||||
|
response.request,
|
||||||
|
response
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the specified URL is absolute
|
||||||
|
*
|
||||||
|
* @param {string} url The URL to test
|
||||||
|
*
|
||||||
|
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
||||||
|
*/
|
||||||
|
function isAbsoluteURL(url) {
|
||||||
|
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
||||||
|
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
||||||
|
// by any combination of letters, digits, plus, period, or hyphen.
|
||||||
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the specified URLs
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} relativeURL The relative URL
|
||||||
|
*
|
||||||
|
* @returns {string} The combined URL
|
||||||
|
*/
|
||||||
|
function combineURLs(baseURL, relativeURL) {
|
||||||
|
return relativeURL
|
||||||
|
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
||||||
|
: baseURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new URL by combining the baseURL with the requestedURL,
|
||||||
|
* only when the requestedURL is not already an absolute URL.
|
||||||
|
* If the requestURL is absolute, this function returns the requestedURL untouched.
|
||||||
|
*
|
||||||
|
* @param {string} baseURL The base URL
|
||||||
|
* @param {string} requestedURL Absolute or relative URL to combine
|
||||||
|
*
|
||||||
|
* @returns {string} The combined full path
|
||||||
|
*/
|
||||||
|
function buildFullPath(baseURL, requestedURL) {
|
||||||
|
if (baseURL && !isAbsoluteURL(requestedURL)) {
|
||||||
|
return combineURLs(baseURL, requestedURL);
|
||||||
|
}
|
||||||
|
return requestedURL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const VERSION = "1.2.0";
|
||||||
|
|
||||||
|
function parseProtocol(url) {
|
||||||
|
const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
||||||
|
return match && match[1] || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse data uri to a Buffer or Blob
|
||||||
|
*
|
||||||
|
* @param {String} uri
|
||||||
|
* @param {?Boolean} asBlob
|
||||||
|
* @param {?Object} options
|
||||||
|
* @param {?Function} options.Blob
|
||||||
|
*
|
||||||
|
* @returns {Buffer|Blob}
|
||||||
|
*/
|
||||||
|
function fromDataURI(uri, asBlob, options) {
|
||||||
|
const _Blob = options && options.Blob || platform.classes.Blob;
|
||||||
|
const protocol = parseProtocol(uri);
|
||||||
|
|
||||||
|
if (asBlob === undefined && _Blob) {
|
||||||
|
asBlob = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (protocol === 'data') {
|
||||||
|
uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
|
||||||
|
|
||||||
|
const match = DATA_URL_PATTERN.exec(uri);
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mime = match[1];
|
||||||
|
const isBase64 = match[2];
|
||||||
|
const body = match[3];
|
||||||
|
const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
|
||||||
|
|
||||||
|
if (asBlob) {
|
||||||
|
if (!_Blob) {
|
||||||
|
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new _Blob([buffer], {type: mime});
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throttle decorator
|
* Throttle decorator
|
||||||
* @param {Function} fn
|
* @param {Function} fn
|
||||||
@@ -2093,8 +2309,10 @@ function setProxy(options, configProxy, location) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
|
||||||
|
|
||||||
/*eslint consistent-return:0*/
|
/*eslint consistent-return:0*/
|
||||||
function httpAdapter(config) {
|
const httpAdapter = isHttpAdapterSupported && function httpAdapter(config) {
|
||||||
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
|
||||||
let data = config.data;
|
let data = config.data;
|
||||||
const responseType = config.responseType;
|
const responseType = config.responseType;
|
||||||
@@ -2364,6 +2582,23 @@ function httpAdapter(config) {
|
|||||||
|
|
||||||
const streams = [res];
|
const streams = [res];
|
||||||
|
|
||||||
|
const responseLength = +res.headers['content-length'];
|
||||||
|
|
||||||
|
if (onDownloadProgress) {
|
||||||
|
const transformStream = new AxiosTransformStream$1({
|
||||||
|
length: utils.toFiniteNumber(responseLength),
|
||||||
|
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
||||||
|
});
|
||||||
|
|
||||||
|
onDownloadProgress && transformStream.on('progress', progress => {
|
||||||
|
onDownloadProgress(Object.assign(progress, {
|
||||||
|
download: true
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
streams.push(transformStream);
|
||||||
|
}
|
||||||
|
|
||||||
// uncompress the response body transparently if required
|
// uncompress the response body transparently if required
|
||||||
let responseStream = res;
|
let responseStream = res;
|
||||||
|
|
||||||
@@ -2374,7 +2609,7 @@ function httpAdapter(config) {
|
|||||||
if (config.decompress !== false) {
|
if (config.decompress !== false) {
|
||||||
// if no content, but headers still say that it is encoded,
|
// if no content, but headers still say that it is encoded,
|
||||||
// remove the header not confuse downstream operations
|
// remove the header not confuse downstream operations
|
||||||
if (data && data.length === 0 && res.headers['content-encoding']) {
|
if ((!responseLength || res.statusCode === 204) && res.headers['content-encoding']) {
|
||||||
delete res.headers['content-encoding'];
|
delete res.headers['content-encoding'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2397,23 +2632,6 @@ function httpAdapter(config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onDownloadProgress) {
|
|
||||||
const responseLength = +res.headers['content-length'];
|
|
||||||
|
|
||||||
const transformStream = new AxiosTransformStream$1({
|
|
||||||
length: utils.toFiniteNumber(responseLength),
|
|
||||||
maxRate: utils.toFiniteNumber(maxDownloadRate)
|
|
||||||
});
|
|
||||||
|
|
||||||
onDownloadProgress && transformStream.on('progress', progress => {
|
|
||||||
onDownloadProgress(Object.assign(progress, {
|
|
||||||
download: true
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
streams.push(transformStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils.noop) : streams[0];
|
responseStream = streams.length > 1 ? stream__default["default"].pipeline(streams, utils.noop) : streams[0];
|
||||||
|
|
||||||
const offListeners = stream__default["default"].finished(responseStream, () => {
|
const offListeners = stream__default["default"].finished(responseStream, () => {
|
||||||
@@ -2577,7 +2795,7 @@ function httpAdapter(config) {
|
|||||||
req.end(data);
|
req.end(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const cookies = platform.isStandardBrowserEnv ?
|
const cookies = platform.isStandardBrowserEnv ?
|
||||||
|
|
||||||
@@ -2719,7 +2937,9 @@ function progressEventReducer(listener, isDownloadStream) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function xhrAdapter(config) {
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
|
||||||
|
|
||||||
|
const xhrAdapter = isXHRAdapterSupported && function (config) {
|
||||||
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
||||||
let requestData = config.data;
|
let requestData = config.data;
|
||||||
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
|
||||||
@@ -2920,240 +3140,63 @@ function xhrAdapter(config) {
|
|||||||
// Send the request
|
// Send the request
|
||||||
request.send(requestData || null);
|
request.send(requestData || null);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
const adapters = {
|
const knownAdapters = {
|
||||||
http: httpAdapter,
|
http: httpAdapter,
|
||||||
xhr: xhrAdapter
|
xhr: xhrAdapter
|
||||||
};
|
};
|
||||||
|
|
||||||
const adapters$1 = {
|
utils.forEach(knownAdapters, (fn, value) => {
|
||||||
getAdapter: (nameOrAdapter) => {
|
if(fn) {
|
||||||
if(utils.isString(nameOrAdapter)){
|
try {
|
||||||
const adapter = adapters[nameOrAdapter];
|
Object.defineProperty(fn, 'name', {value});
|
||||||
|
} catch (e) {
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
}
|
||||||
|
Object.defineProperty(fn, 'adapterName', {value});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (!nameOrAdapter) {
|
const adapters = {
|
||||||
throw Error(
|
getAdapter: (adapters) => {
|
||||||
utils.hasOwnProp(nameOrAdapter) ?
|
adapters = utils.isArray(adapters) ? adapters : [adapters];
|
||||||
`Adapter '${nameOrAdapter}' is not available in the build` :
|
|
||||||
`Can not resolve adapter '${nameOrAdapter}'`
|
const {length} = adapters;
|
||||||
|
let nameOrAdapter;
|
||||||
|
let adapter;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
nameOrAdapter = adapters[i];
|
||||||
|
if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!adapter) {
|
||||||
|
if (adapter === false) {
|
||||||
|
throw new AxiosError(
|
||||||
|
`Adapter ${nameOrAdapter} is not supported by the environment`,
|
||||||
|
'ERR_NOT_SUPPORT'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return adapter
|
throw new Error(
|
||||||
|
utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
|
||||||
|
`Adapter '${nameOrAdapter}' is not available in the build` :
|
||||||
|
`Unknown adapter '${nameOrAdapter}'`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!utils.isFunction(nameOrAdapter)) {
|
if (!utils.isFunction(adapter)) {
|
||||||
throw new TypeError('adapter is not a function');
|
throw new TypeError('adapter is not a function');
|
||||||
}
|
}
|
||||||
|
|
||||||
return nameOrAdapter;
|
return adapter;
|
||||||
},
|
},
|
||||||
adapters
|
adapters: knownAdapters
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_CONTENT_TYPE = {
|
|
||||||
'Content-Type': undefined
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
|
|
||||||
* adapter
|
|
||||||
*
|
|
||||||
* @returns {Function}
|
|
||||||
*/
|
|
||||||
function getDefaultAdapter() {
|
|
||||||
let adapter;
|
|
||||||
if (typeof XMLHttpRequest !== 'undefined') {
|
|
||||||
// For browsers use XHR adapter
|
|
||||||
adapter = adapters$1.getAdapter('xhr');
|
|
||||||
} else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
|
|
||||||
// For node use HTTP adapter
|
|
||||||
adapter = adapters$1.getAdapter('http');
|
|
||||||
}
|
|
||||||
return adapter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* It takes a string, tries to parse it, and if it fails, it returns the stringified version
|
|
||||||
* of the input
|
|
||||||
*
|
|
||||||
* @param {any} rawValue - The value to be stringified.
|
|
||||||
* @param {Function} parser - A function that parses a string into a JavaScript object.
|
|
||||||
* @param {Function} encoder - A function that takes a value and returns a string.
|
|
||||||
*
|
|
||||||
* @returns {string} A stringified version of the rawValue.
|
|
||||||
*/
|
|
||||||
function stringifySafely(rawValue, parser, encoder) {
|
|
||||||
if (utils.isString(rawValue)) {
|
|
||||||
try {
|
|
||||||
(parser || JSON.parse)(rawValue);
|
|
||||||
return utils.trim(rawValue);
|
|
||||||
} catch (e) {
|
|
||||||
if (e.name !== 'SyntaxError') {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (encoder || JSON.stringify)(rawValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaults = {
|
|
||||||
|
|
||||||
transitional: transitionalDefaults,
|
|
||||||
|
|
||||||
adapter: getDefaultAdapter(),
|
|
||||||
|
|
||||||
transformRequest: [function transformRequest(data, headers) {
|
|
||||||
const contentType = headers.getContentType() || '';
|
|
||||||
const hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
||||||
const isObjectPayload = utils.isObject(data);
|
|
||||||
|
|
||||||
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
||||||
data = new FormData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isFormData = utils.isFormData(data);
|
|
||||||
|
|
||||||
if (isFormData) {
|
|
||||||
if (!hasJSONContentType) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.isArrayBuffer(data) ||
|
|
||||||
utils.isBuffer(data) ||
|
|
||||||
utils.isStream(data) ||
|
|
||||||
utils.isFile(data) ||
|
|
||||||
utils.isBlob(data)
|
|
||||||
) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
if (utils.isArrayBufferView(data)) {
|
|
||||||
return data.buffer;
|
|
||||||
}
|
|
||||||
if (utils.isURLSearchParams(data)) {
|
|
||||||
headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
|
|
||||||
return data.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
let isFileList;
|
|
||||||
|
|
||||||
if (isObjectPayload) {
|
|
||||||
if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
|
|
||||||
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
||||||
const _FormData = this.env && this.env.FormData;
|
|
||||||
|
|
||||||
return toFormData(
|
|
||||||
isFileList ? {'files[]': data} : data,
|
|
||||||
_FormData && new _FormData(),
|
|
||||||
this.formSerializer
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isObjectPayload || hasJSONContentType ) {
|
|
||||||
headers.setContentType('application/json', false);
|
|
||||||
return stringifySafely(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
|
|
||||||
transformResponse: [function transformResponse(data) {
|
|
||||||
const transitional = this.transitional || defaults.transitional;
|
|
||||||
const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
||||||
const JSONRequested = this.responseType === 'json';
|
|
||||||
|
|
||||||
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
||||||
const silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
||||||
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return JSON.parse(data);
|
|
||||||
} catch (e) {
|
|
||||||
if (strictJSONParsing) {
|
|
||||||
if (e.name === 'SyntaxError') {
|
|
||||||
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}],
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
||||||
* timeout is not created.
|
|
||||||
*/
|
|
||||||
timeout: 0,
|
|
||||||
|
|
||||||
xsrfCookieName: 'XSRF-TOKEN',
|
|
||||||
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
||||||
|
|
||||||
maxContentLength: -1,
|
|
||||||
maxBodyLength: -1,
|
|
||||||
|
|
||||||
env: {
|
|
||||||
FormData: platform.classes.FormData,
|
|
||||||
Blob: platform.classes.Blob
|
|
||||||
},
|
|
||||||
|
|
||||||
validateStatus: function validateStatus(status) {
|
|
||||||
return status >= 200 && status < 300;
|
|
||||||
},
|
|
||||||
|
|
||||||
headers: {
|
|
||||||
common: {
|
|
||||||
'Accept': 'application/json, text/plain, */*'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
|
||||||
defaults.headers[method] = {};
|
|
||||||
});
|
|
||||||
|
|
||||||
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
||||||
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
|
||||||
});
|
|
||||||
|
|
||||||
const defaults$1 = defaults;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transform the data for a request or a response
|
|
||||||
*
|
|
||||||
* @param {Array|Function} fns A single function or Array of functions
|
|
||||||
* @param {?Object} response The response object
|
|
||||||
*
|
|
||||||
* @returns {*} The resulting transformed data
|
|
||||||
*/
|
|
||||||
function transformData(fns, response) {
|
|
||||||
const config = this || defaults$1;
|
|
||||||
const context = response || config;
|
|
||||||
const headers = AxiosHeaders$1.from(context.headers);
|
|
||||||
let data = context.data;
|
|
||||||
|
|
||||||
utils.forEach(fns, function transform(fn) {
|
|
||||||
data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
headers.normalize();
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isCancel(value) {
|
|
||||||
return !!(value && value.__CANCEL__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Throws a `CanceledError` if cancellation has been requested.
|
* Throws a `CanceledError` if cancellation has been requested.
|
||||||
*
|
*
|
||||||
@@ -3193,7 +3236,7 @@ function dispatchRequest(config) {
|
|||||||
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
config.headers.setContentType('application/x-www-form-urlencoded', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const adapter = config.adapter || defaults$1.adapter;
|
const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
|
||||||
|
|
||||||
return adapter(config).then(function onAdapterResolution(response) {
|
return adapter(config).then(function onAdapterResolution(response) {
|
||||||
throwIfCancellationRequested(config);
|
throwIfCancellationRequested(config);
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
export const VERSION = "1.2.0-alpha.1";
|
export const VERSION = "1.2.0";
|
||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "axios",
|
"name": "axios",
|
||||||
"version": "1.2.0-alpha.1",
|
"version": "1.2.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "axios",
|
"name": "axios",
|
||||||
"version": "1.2.0-alpha.1",
|
"version": "1.2.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"follow-redirects": "^1.15.0",
|
"follow-redirects": "^1.15.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "axios",
|
"name": "axios",
|
||||||
"version": "1.2.0-alpha.1",
|
"version": "1.2.0",
|
||||||
"description": "Promise based HTTP client for the browser and node.js",
|
"description": "Promise based HTTP client for the browser and node.js",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
Reference in New Issue
Block a user