@bundled-es-modules/axios
Advanced tools
Comparing version 0.18.1 to 0.21.1
1055
axios.js
@@ -1,9 +0,11 @@ | ||
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
function createCommonjsModule(fn) { | ||
var module = { exports: {} }; | ||
return fn(module, module.exports), module.exports; | ||
} | ||
/* axios v0.21.1 | (c) 2020 by Matt Zabriskie */ | ||
var axios = createCommonjsModule(function (module, exports) { | ||
/* axios v0.18.1 | (c) 2019 by Matt Zabriskie */ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
@@ -66,4 +68,5 @@ module.exports = factory(); | ||
var bind = __webpack_require__(3); | ||
var Axios = __webpack_require__(5); | ||
var defaults = __webpack_require__(6); | ||
var Axios = __webpack_require__(4); | ||
var mergeConfig = __webpack_require__(22); | ||
var defaults = __webpack_require__(10); | ||
@@ -97,9 +100,9 @@ /** | ||
axios.create = function create(instanceConfig) { | ||
return createInstance(utils.merge(defaults, instanceConfig)); | ||
return createInstance(mergeConfig(axios.defaults, instanceConfig)); | ||
}; | ||
// Expose Cancel & CancelToken | ||
axios.Cancel = __webpack_require__(22); | ||
axios.CancelToken = __webpack_require__(23); | ||
axios.isCancel = __webpack_require__(19); | ||
axios.Cancel = __webpack_require__(23); | ||
axios.CancelToken = __webpack_require__(24); | ||
axios.isCancel = __webpack_require__(9); | ||
@@ -110,4 +113,7 @@ // Expose all/spread | ||
}; | ||
axios.spread = __webpack_require__(24); | ||
axios.spread = __webpack_require__(25); | ||
// Expose isAxiosError | ||
axios.isAxiosError = __webpack_require__(26); | ||
module.exports = axios; | ||
@@ -124,3 +130,2 @@ | ||
var bind = __webpack_require__(3); | ||
var isBuffer = __webpack_require__(4); | ||
@@ -144,2 +149,23 @@ /*global toString:true*/ | ||
/** | ||
* Determine if a value is undefined | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if the value is undefined, otherwise false | ||
*/ | ||
function isUndefined(val) { | ||
return typeof val === 'undefined'; | ||
} | ||
/** | ||
* Determine if a value is a Buffer | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is a Buffer, otherwise false | ||
*/ | ||
function isBuffer(val) { | ||
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) | ||
&& typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); | ||
} | ||
/** | ||
* Determine if a value is an ArrayBuffer | ||
@@ -201,19 +227,24 @@ * | ||
/** | ||
* Determine if a value is undefined | ||
* Determine if a value is an Object | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if the value is undefined, otherwise false | ||
* @returns {boolean} True if value is an Object, otherwise false | ||
*/ | ||
function isUndefined(val) { | ||
return typeof val === 'undefined'; | ||
function isObject(val) { | ||
return val !== null && typeof val === 'object'; | ||
} | ||
/** | ||
* Determine if a value is an Object | ||
* Determine if a value is a plain Object | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an Object, otherwise false | ||
* @return {boolean} True if value is a plain Object, otherwise false | ||
*/ | ||
function isObject(val) { | ||
return val !== null && typeof val === 'object'; | ||
function isPlainObject(val) { | ||
if (toString.call(val) !== '[object Object]') { | ||
return false; | ||
} | ||
var prototype = Object.getPrototypeOf(val); | ||
return prototype === null || prototype === Object.prototype; | ||
} | ||
@@ -303,5 +334,9 @@ | ||
* navigator.product -> 'ReactNative' | ||
* nativescript | ||
* navigator.product -> 'NativeScript' or 'NS' | ||
*/ | ||
function isStandardBrowserEnv() { | ||
if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') { | ||
if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || | ||
navigator.product === 'NativeScript' || | ||
navigator.product === 'NS')) { | ||
return false; | ||
@@ -374,4 +409,8 @@ } | ||
function assignValue(val, key) { | ||
if (typeof result[key] === 'object' && typeof val === 'object') { | ||
if (isPlainObject(result[key]) && isPlainObject(val)) { | ||
result[key] = merge(result[key], val); | ||
} else if (isPlainObject(val)) { | ||
result[key] = merge({}, val); | ||
} else if (isArray(val)) { | ||
result[key] = val.slice(); | ||
} else { | ||
@@ -407,2 +446,15 @@ result[key] = val; | ||
/** | ||
* Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) | ||
* | ||
* @param {string} content with BOM | ||
* @return {string} content value without BOM | ||
*/ | ||
function stripBOM(content) { | ||
if (content.charCodeAt(0) === 0xFEFF) { | ||
content = content.slice(1); | ||
} | ||
return content; | ||
} | ||
module.exports = { | ||
@@ -417,2 +469,3 @@ isArray: isArray, | ||
isObject: isObject, | ||
isPlainObject: isPlainObject, | ||
isUndefined: isUndefined, | ||
@@ -429,3 +482,4 @@ isDate: isDate, | ||
extend: extend, | ||
trim: trim | ||
trim: trim, | ||
stripBOM: stripBOM | ||
}; | ||
@@ -451,25 +505,9 @@ | ||
/* 4 */ | ||
/***/ (function(module, exports) { | ||
/*! | ||
* Determine if an object is a Buffer | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
module.exports = function isBuffer (obj) { | ||
return obj != null && obj.constructor != null && | ||
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) | ||
}; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var defaults = __webpack_require__(6); | ||
var utils = __webpack_require__(2); | ||
var InterceptorManager = __webpack_require__(16); | ||
var dispatchRequest = __webpack_require__(17); | ||
var buildURL = __webpack_require__(5); | ||
var InterceptorManager = __webpack_require__(6); | ||
var dispatchRequest = __webpack_require__(7); | ||
var mergeConfig = __webpack_require__(22); | ||
@@ -498,10 +536,19 @@ /** | ||
if (typeof config === 'string') { | ||
config = utils.merge({ | ||
url: arguments[0] | ||
}, arguments[1]); | ||
config = arguments[1] || {}; | ||
config.url = arguments[0]; | ||
} else { | ||
config = config || {}; | ||
} | ||
config = utils.merge(defaults, {method: 'get'}, this.defaults, config); | ||
config.method = config.method.toLowerCase(); | ||
config = mergeConfig(this.defaults, config); | ||
// Set config.method | ||
if (config.method) { | ||
config.method = config.method.toLowerCase(); | ||
} else if (this.defaults.method) { | ||
config.method = this.defaults.method.toLowerCase(); | ||
} else { | ||
config.method = 'get'; | ||
} | ||
// Hook up interceptors middleware | ||
@@ -526,2 +573,7 @@ var chain = [dispatchRequest, undefined]; | ||
Axios.prototype.getUri = function getUri(config) { | ||
config = mergeConfig(this.defaults, config); | ||
return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); | ||
}; | ||
// Provide aliases for supported request methods | ||
@@ -531,5 +583,6 @@ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { | ||
Axios.prototype[method] = function(url, config) { | ||
return this.request(utils.merge(config || {}, { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
url: url | ||
url: url, | ||
data: (config || {}).data | ||
})); | ||
@@ -542,3 +595,3 @@ }; | ||
Axios.prototype[method] = function(url, data, config) { | ||
return this.request(utils.merge(config || {}, { | ||
return this.request(mergeConfig(config || {}, { | ||
method: method, | ||
@@ -555,2 +608,76 @@ url: url, | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
function encode(val) { | ||
return encodeURIComponent(val). | ||
replace(/%3A/gi, ':'). | ||
replace(/%24/g, '$'). | ||
replace(/%2C/gi, ','). | ||
replace(/%20/g, '+'). | ||
replace(/%5B/gi, '['). | ||
replace(/%5D/gi, ']'); | ||
} | ||
/** | ||
* Build a URL by appending params to the end | ||
* | ||
* @param {string} url The base of the url (e.g., http://www.google.com) | ||
* @param {object} [params] The params to be appended | ||
* @returns {string} The formatted url | ||
*/ | ||
module.exports = function buildURL(url, params, paramsSerializer) { | ||
/*eslint no-param-reassign:0*/ | ||
if (!params) { | ||
return url; | ||
} | ||
var serializedParams; | ||
if (paramsSerializer) { | ||
serializedParams = paramsSerializer(params); | ||
} else if (utils.isURLSearchParams(params)) { | ||
serializedParams = params.toString(); | ||
} else { | ||
var parts = []; | ||
utils.forEach(params, function serialize(val, key) { | ||
if (val === null || typeof val === 'undefined') { | ||
return; | ||
} | ||
if (utils.isArray(val)) { | ||
key = key + '[]'; | ||
} else { | ||
val = [val]; | ||
} | ||
utils.forEach(val, function parseValue(v) { | ||
if (utils.isDate(v)) { | ||
v = v.toISOString(); | ||
} else if (utils.isObject(v)) { | ||
v = JSON.stringify(v); | ||
} | ||
parts.push(encode(key) + '=' + encode(v)); | ||
}); | ||
}); | ||
serializedParams = parts.join('&'); | ||
} | ||
if (serializedParams) { | ||
var hashmarkIndex = url.indexOf('#'); | ||
if (hashmarkIndex !== -1) { | ||
url = url.slice(0, hashmarkIndex); | ||
} | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; | ||
} | ||
return url; | ||
}; | ||
/***/ }), | ||
/* 6 */ | ||
@@ -560,4 +687,176 @@ /***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
var normalizeHeaderName = __webpack_require__(7); | ||
function InterceptorManager() { | ||
this.handlers = []; | ||
} | ||
/** | ||
* Add a new interceptor to the stack | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
*/ | ||
InterceptorManager.prototype.use = function use(fulfilled, rejected) { | ||
this.handlers.push({ | ||
fulfilled: fulfilled, | ||
rejected: rejected | ||
}); | ||
return this.handlers.length - 1; | ||
}; | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
*/ | ||
InterceptorManager.prototype.eject = function eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
} | ||
}; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
*/ | ||
InterceptorManager.prototype.forEach = function forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
} | ||
}); | ||
}; | ||
module.exports = InterceptorManager; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
var transformData = __webpack_require__(8); | ||
var isCancel = __webpack_require__(9); | ||
var defaults = __webpack_require__(10); | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
*/ | ||
function throwIfCancellationRequested(config) { | ||
if (config.cancelToken) { | ||
config.cancelToken.throwIfRequested(); | ||
} | ||
} | ||
/** | ||
* Dispatch a request to the server using the configured adapter. | ||
* | ||
* @param {object} config The config that is to be used for the request | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
module.exports = function dispatchRequest(config) { | ||
throwIfCancellationRequested(config); | ||
// Ensure headers exist | ||
config.headers = config.headers || {}; | ||
// Transform request data | ||
config.data = transformData( | ||
config.data, | ||
config.headers, | ||
config.transformRequest | ||
); | ||
// Flatten headers | ||
config.headers = utils.merge( | ||
config.headers.common || {}, | ||
config.headers[config.method] || {}, | ||
config.headers | ||
); | ||
utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
} | ||
); | ||
var adapter = config.adapter || defaults.adapter; | ||
return adapter(config).then(function onAdapterResolution(response) { | ||
throwIfCancellationRequested(config); | ||
// Transform response data | ||
response.data = transformData( | ||
response.data, | ||
response.headers, | ||
config.transformResponse | ||
); | ||
return response; | ||
}, function onAdapterRejection(reason) { | ||
if (!isCancel(reason)) { | ||
throwIfCancellationRequested(config); | ||
// Transform response data | ||
if (reason && reason.response) { | ||
reason.response.data = transformData( | ||
reason.response.data, | ||
reason.response.headers, | ||
config.transformResponse | ||
); | ||
} | ||
} | ||
return Promise.reject(reason); | ||
}); | ||
}; | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
/** | ||
* Transform the data for a request or a response | ||
* | ||
* @param {Object|String} data The data to be transformed | ||
* @param {Array} headers The headers for the request or response | ||
* @param {Array|Function} fns A single function or Array of functions | ||
* @returns {*} The resulting transformed data | ||
*/ | ||
module.exports = function transformData(data, headers, fns) { | ||
/*eslint no-param-reassign:0*/ | ||
utils.forEach(fns, function transform(fn) { | ||
data = fn(data, headers); | ||
}); | ||
return data; | ||
}; | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
module.exports = function isCancel(value) { | ||
return !!(value && value.__CANCEL__); | ||
}; | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
var normalizeHeaderName = __webpack_require__(11); | ||
var DEFAULT_CONTENT_TYPE = { | ||
@@ -577,6 +876,6 @@ 'Content-Type': 'application/x-www-form-urlencoded' | ||
// For browsers use XHR adapter | ||
adapter = __webpack_require__(8); | ||
} else if (typeof process !== 'undefined') { | ||
adapter = __webpack_require__(12); | ||
} else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { | ||
// For node use HTTP adapter | ||
adapter = __webpack_require__(8); | ||
adapter = __webpack_require__(12); | ||
} | ||
@@ -590,2 +889,3 @@ return adapter; | ||
transformRequest: [function transformRequest(data, headers) { | ||
normalizeHeaderName(headers, 'Accept'); | ||
normalizeHeaderName(headers, 'Content-Type'); | ||
@@ -635,2 +935,3 @@ if (utils.isFormData(data) || | ||
maxContentLength: -1, | ||
maxBodyLength: -1, | ||
@@ -660,3 +961,3 @@ validateStatus: function validateStatus(status) { | ||
/***/ }), | ||
/* 7 */ | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -677,11 +978,13 @@ | ||
/***/ }), | ||
/* 8 */ | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
var settle = __webpack_require__(9); | ||
var buildURL = __webpack_require__(12); | ||
var parseHeaders = __webpack_require__(13); | ||
var isURLSameOrigin = __webpack_require__(14); | ||
var createError = __webpack_require__(10); | ||
var settle = __webpack_require__(13); | ||
var cookies = __webpack_require__(16); | ||
var buildURL = __webpack_require__(5); | ||
var buildFullPath = __webpack_require__(17); | ||
var parseHeaders = __webpack_require__(20); | ||
var isURLSameOrigin = __webpack_require__(21); | ||
var createError = __webpack_require__(14); | ||
@@ -702,7 +1005,8 @@ module.exports = function xhrAdapter(config) { | ||
var username = config.auth.username || ''; | ||
var password = config.auth.password || ''; | ||
var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; | ||
requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); | ||
} | ||
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true); | ||
var fullPath = buildFullPath(config.baseURL, config.url); | ||
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); | ||
@@ -744,2 +1048,14 @@ // Set the request timeout in MS | ||
// Handle browser request cancellation (as opposed to a manual cancellation) | ||
request.onabort = function handleAbort() { | ||
if (!request) { | ||
return; | ||
} | ||
reject(createError('Request aborted', config, 'ECONNABORTED', request)); | ||
// Clean up request | ||
request = null; | ||
}; | ||
// Handle low level network errors | ||
@@ -757,3 +1073,7 @@ request.onerror = function handleError() { | ||
request.ontimeout = function handleTimeout() { | ||
reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED', | ||
var timeoutErrorMessage = 'timeout of ' + config.timeout + 'ms exceeded'; | ||
if (config.timeoutErrorMessage) { | ||
timeoutErrorMessage = config.timeoutErrorMessage; | ||
} | ||
reject(createError(timeoutErrorMessage, config, 'ECONNABORTED', | ||
request)); | ||
@@ -769,8 +1089,6 @@ | ||
if (utils.isStandardBrowserEnv()) { | ||
var cookies = __webpack_require__(15); | ||
// Add xsrf header | ||
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? | ||
cookies.read(config.xsrfCookieName) : | ||
undefined; | ||
var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? | ||
cookies.read(config.xsrfCookieName) : | ||
undefined; | ||
@@ -796,4 +1114,4 @@ if (xsrfValue) { | ||
// Add withCredentials to request if needed | ||
if (config.withCredentials) { | ||
request.withCredentials = true; | ||
if (!utils.isUndefined(config.withCredentials)) { | ||
request.withCredentials = !!config.withCredentials; | ||
} | ||
@@ -838,3 +1156,3 @@ | ||
if (requestData === undefined) { | ||
if (!requestData) { | ||
requestData = null; | ||
@@ -850,6 +1168,6 @@ } | ||
/***/ }), | ||
/* 9 */ | ||
/* 13 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var createError = __webpack_require__(10); | ||
var createError = __webpack_require__(14); | ||
@@ -865,3 +1183,2 @@ /** | ||
var validateStatus = response.config.validateStatus; | ||
// Note: status is not exposed by XDomainRequest | ||
if (!response.status || !validateStatus || validateStatus(response.status)) { | ||
@@ -882,6 +1199,6 @@ resolve(response); | ||
/***/ }), | ||
/* 10 */ | ||
/* 14 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var enhanceError = __webpack_require__(11); | ||
var enhanceError = __webpack_require__(15); | ||
@@ -905,3 +1222,3 @@ /** | ||
/***/ }), | ||
/* 11 */ | ||
/* 15 */ | ||
/***/ (function(module, exports) { | ||
@@ -924,4 +1241,25 @@ | ||
} | ||
error.request = request; | ||
error.response = response; | ||
error.isAxiosError = true; | ||
error.toJSON = function toJSON() { | ||
return { | ||
// Standard | ||
message: this.message, | ||
name: this.name, | ||
// Microsoft | ||
description: this.description, | ||
number: this.number, | ||
// Mozilla | ||
fileName: this.fileName, | ||
lineNumber: this.lineNumber, | ||
columnNumber: this.columnNumber, | ||
stack: this.stack, | ||
// Axios | ||
config: this.config, | ||
code: this.code | ||
}; | ||
}; | ||
return error; | ||
@@ -932,3 +1270,3 @@ }; | ||
/***/ }), | ||
/* 12 */ | ||
/* 16 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -938,63 +1276,92 @@ | ||
function encode(val) { | ||
return encodeURIComponent(val). | ||
replace(/%40/gi, '@'). | ||
replace(/%3A/gi, ':'). | ||
replace(/%24/g, '$'). | ||
replace(/%2C/gi, ','). | ||
replace(/%20/g, '+'). | ||
replace(/%5B/gi, '['). | ||
replace(/%5D/gi, ']'); | ||
} | ||
module.exports = ( | ||
utils.isStandardBrowserEnv() ? | ||
/** | ||
* Build a URL by appending params to the end | ||
* | ||
* @param {string} url The base of the url (e.g., http://www.google.com) | ||
* @param {object} [params] The params to be appended | ||
* @returns {string} The formatted url | ||
*/ | ||
module.exports = function buildURL(url, params, paramsSerializer) { | ||
/*eslint no-param-reassign:0*/ | ||
if (!params) { | ||
return url; | ||
} | ||
// 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)); | ||
var serializedParams; | ||
if (paramsSerializer) { | ||
serializedParams = paramsSerializer(params); | ||
} else if (utils.isURLSearchParams(params)) { | ||
serializedParams = params.toString(); | ||
} else { | ||
var parts = []; | ||
if (utils.isNumber(expires)) { | ||
cookie.push('expires=' + new Date(expires).toGMTString()); | ||
} | ||
utils.forEach(params, function serialize(val, key) { | ||
if (val === null || typeof val === 'undefined') { | ||
return; | ||
} | ||
if (utils.isString(path)) { | ||
cookie.push('path=' + path); | ||
} | ||
if (utils.isArray(val)) { | ||
key = key + '[]'; | ||
} else { | ||
val = [val]; | ||
} | ||
if (utils.isString(domain)) { | ||
cookie.push('domain=' + domain); | ||
} | ||
utils.forEach(val, function parseValue(v) { | ||
if (utils.isDate(v)) { | ||
v = v.toISOString(); | ||
} else if (utils.isObject(v)) { | ||
v = JSON.stringify(v); | ||
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); | ||
} | ||
parts.push(encode(key) + '=' + encode(v)); | ||
}); | ||
}); | ||
}; | ||
})() : | ||
serializedParams = parts.join('&'); | ||
} | ||
// 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() {} | ||
}; | ||
})() | ||
); | ||
/***/ }), | ||
/* 17 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
if (serializedParams) { | ||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; | ||
var isAbsoluteURL = __webpack_require__(18); | ||
var combineURLs = __webpack_require__(19); | ||
/** | ||
* 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 | ||
*/ | ||
module.exports = function buildFullPath(baseURL, requestedURL) { | ||
if (baseURL && !isAbsoluteURL(requestedURL)) { | ||
return combineURLs(baseURL, requestedURL); | ||
} | ||
return requestedURL; | ||
}; | ||
/***/ }), | ||
/* 18 */ | ||
/***/ (function(module, exports) { | ||
return url; | ||
/** | ||
* 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 | ||
*/ | ||
module.exports = 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); | ||
}; | ||
@@ -1004,3 +1371,21 @@ | ||
/***/ }), | ||
/* 13 */ | ||
/* 19 */ | ||
/***/ (function(module, exports) { | ||
/** | ||
* 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 | ||
*/ | ||
module.exports = function combineURLs(baseURL, relativeURL) { | ||
return relativeURL | ||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') | ||
: baseURL; | ||
}; | ||
/***/ }), | ||
/* 20 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1062,3 +1447,3 @@ | ||
/***/ }), | ||
/* 14 */ | ||
/* 21 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1073,8 +1458,8 @@ | ||
// 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; | ||
(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 | ||
@@ -1085,31 +1470,31 @@ * | ||
*/ | ||
function resolveURL(url) { | ||
var href = url; | ||
function resolveURL(url) { | ||
var href = url; | ||
if (msie) { | ||
if (msie) { | ||
// IE needs attribute set twice to normalize properties | ||
urlParsingNode.setAttribute('href', href); | ||
href = urlParsingNode.href; | ||
} | ||
urlParsingNode.setAttribute('href', href); | ||
href = urlParsingNode.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 | ||
}; | ||
} | ||
urlParsingNode.setAttribute('href', href); | ||
originURL = resolveURL(window.location.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 | ||
@@ -1120,15 +1505,15 @@ * | ||
*/ | ||
return function isURLSameOrigin(requestURL) { | ||
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; | ||
return (parsed.protocol === originURL.protocol && | ||
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 nonStandardBrowserEnv() { | ||
return function isURLSameOrigin() { | ||
return true; | ||
}; | ||
})() | ||
); | ||
@@ -1138,3 +1523,3 @@ | ||
/***/ }), | ||
/* 15 */ | ||
/* 22 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1144,265 +1529,84 @@ | ||
module.exports = ( | ||
utils.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() {} | ||
}; | ||
})() | ||
); | ||
/***/ }), | ||
/* 16 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
function InterceptorManager() { | ||
this.handlers = []; | ||
} | ||
/** | ||
* Add a new interceptor to the stack | ||
* Config-specific merge-function which creates a new config-object | ||
* by merging two configuration objects together. | ||
* | ||
* @param {Function} fulfilled The function to handle `then` for a `Promise` | ||
* @param {Function} rejected The function to handle `reject` for a `Promise` | ||
* | ||
* @return {Number} An ID used to remove interceptor later | ||
* @param {Object} config1 | ||
* @param {Object} config2 | ||
* @returns {Object} New object resulting from merging config2 to config1 | ||
*/ | ||
InterceptorManager.prototype.use = function use(fulfilled, rejected) { | ||
this.handlers.push({ | ||
fulfilled: fulfilled, | ||
rejected: rejected | ||
}); | ||
return this.handlers.length - 1; | ||
}; | ||
module.exports = function mergeConfig(config1, config2) { | ||
// eslint-disable-next-line no-param-reassign | ||
config2 = config2 || {}; | ||
var config = {}; | ||
/** | ||
* Remove an interceptor from the stack | ||
* | ||
* @param {Number} id The ID that was returned by `use` | ||
*/ | ||
InterceptorManager.prototype.eject = function eject(id) { | ||
if (this.handlers[id]) { | ||
this.handlers[id] = null; | ||
} | ||
}; | ||
var valueFromConfig2Keys = ['url', 'method', 'data']; | ||
var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params']; | ||
var defaultToConfig2Keys = [ | ||
'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer', | ||
'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName', | ||
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress', | ||
'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent', | ||
'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding' | ||
]; | ||
var directMergeKeys = ['validateStatus']; | ||
/** | ||
* Iterate over all the registered interceptors | ||
* | ||
* This method is particularly useful for skipping over any | ||
* interceptors that may have become `null` calling `eject`. | ||
* | ||
* @param {Function} fn The function to call for each interceptor | ||
*/ | ||
InterceptorManager.prototype.forEach = function forEach(fn) { | ||
utils.forEach(this.handlers, function forEachHandler(h) { | ||
if (h !== null) { | ||
fn(h); | ||
function getMergedValue(target, source) { | ||
if (utils.isPlainObject(target) && utils.isPlainObject(source)) { | ||
return utils.merge(target, source); | ||
} else if (utils.isPlainObject(source)) { | ||
return utils.merge({}, source); | ||
} else if (utils.isArray(source)) { | ||
return source.slice(); | ||
} | ||
}); | ||
}; | ||
module.exports = InterceptorManager; | ||
/***/ }), | ||
/* 17 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
var transformData = __webpack_require__(18); | ||
var isCancel = __webpack_require__(19); | ||
var defaults = __webpack_require__(6); | ||
var isAbsoluteURL = __webpack_require__(20); | ||
var combineURLs = __webpack_require__(21); | ||
/** | ||
* Throws a `Cancel` if cancellation has been requested. | ||
*/ | ||
function throwIfCancellationRequested(config) { | ||
if (config.cancelToken) { | ||
config.cancelToken.throwIfRequested(); | ||
return source; | ||
} | ||
} | ||
/** | ||
* Dispatch a request to the server using the configured adapter. | ||
* | ||
* @param {object} config The config that is to be used for the request | ||
* @returns {Promise} The Promise to be fulfilled | ||
*/ | ||
module.exports = function dispatchRequest(config) { | ||
throwIfCancellationRequested(config); | ||
// Support baseURL config | ||
if (config.baseURL && !isAbsoluteURL(config.url)) { | ||
config.url = combineURLs(config.baseURL, config.url); | ||
function mergeDeepProperties(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
config[prop] = getMergedValue(config1[prop], config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
config[prop] = getMergedValue(undefined, config1[prop]); | ||
} | ||
} | ||
// Ensure headers exist | ||
config.headers = config.headers || {}; | ||
// Transform request data | ||
config.data = transformData( | ||
config.data, | ||
config.headers, | ||
config.transformRequest | ||
); | ||
// Flatten headers | ||
config.headers = utils.merge( | ||
config.headers.common || {}, | ||
config.headers[config.method] || {}, | ||
config.headers || {} | ||
); | ||
utils.forEach( | ||
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], | ||
function cleanHeaderConfig(method) { | ||
delete config.headers[method]; | ||
utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
config[prop] = getMergedValue(undefined, config2[prop]); | ||
} | ||
); | ||
}); | ||
var adapter = config.adapter || defaults.adapter; | ||
utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties); | ||
return adapter(config).then(function onAdapterResolution(response) { | ||
throwIfCancellationRequested(config); | ||
// Transform response data | ||
response.data = transformData( | ||
response.data, | ||
response.headers, | ||
config.transformResponse | ||
); | ||
return response; | ||
}, function onAdapterRejection(reason) { | ||
if (!isCancel(reason)) { | ||
throwIfCancellationRequested(config); | ||
// Transform response data | ||
if (reason && reason.response) { | ||
reason.response.data = transformData( | ||
reason.response.data, | ||
reason.response.headers, | ||
config.transformResponse | ||
); | ||
} | ||
utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) { | ||
if (!utils.isUndefined(config2[prop])) { | ||
config[prop] = getMergedValue(undefined, config2[prop]); | ||
} else if (!utils.isUndefined(config1[prop])) { | ||
config[prop] = getMergedValue(undefined, config1[prop]); | ||
} | ||
return Promise.reject(reason); | ||
}); | ||
}; | ||
/***/ }), | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var utils = __webpack_require__(2); | ||
/** | ||
* Transform the data for a request or a response | ||
* | ||
* @param {Object|String} data The data to be transformed | ||
* @param {Array} headers The headers for the request or response | ||
* @param {Array|Function} fns A single function or Array of functions | ||
* @returns {*} The resulting transformed data | ||
*/ | ||
module.exports = function transformData(data, headers, fns) { | ||
/*eslint no-param-reassign:0*/ | ||
utils.forEach(fns, function transform(fn) { | ||
data = fn(data, headers); | ||
utils.forEach(directMergeKeys, function merge(prop) { | ||
if (prop in config2) { | ||
config[prop] = getMergedValue(config1[prop], config2[prop]); | ||
} else if (prop in config1) { | ||
config[prop] = getMergedValue(undefined, config1[prop]); | ||
} | ||
}); | ||
return data; | ||
}; | ||
/***/ }), | ||
/* 19 */ | ||
/***/ (function(module, exports) { | ||
var axiosKeys = valueFromConfig2Keys | ||
.concat(mergeDeepPropertiesKeys) | ||
.concat(defaultToConfig2Keys) | ||
.concat(directMergeKeys); | ||
module.exports = function isCancel(value) { | ||
return !!(value && value.__CANCEL__); | ||
}; | ||
/***/ }), | ||
/* 20 */ | ||
/***/ (function(module, exports) { | ||
var otherKeys = Object | ||
.keys(config1) | ||
.concat(Object.keys(config2)) | ||
.filter(function filterAxiosKeys(key) { | ||
return axiosKeys.indexOf(key) === -1; | ||
}); | ||
/** | ||
* 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 | ||
*/ | ||
module.exports = 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); | ||
}; | ||
/***/ }), | ||
/* 21 */ | ||
/***/ (function(module, exports) { | ||
utils.forEach(otherKeys, mergeDeepProperties); | ||
/** | ||
* 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 | ||
*/ | ||
module.exports = function combineURLs(baseURL, relativeURL) { | ||
return relativeURL | ||
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') | ||
: baseURL; | ||
return config; | ||
}; | ||
@@ -1412,3 +1616,3 @@ | ||
/***/ }), | ||
/* 22 */ | ||
/* 23 */ | ||
/***/ (function(module, exports) { | ||
@@ -1436,6 +1640,6 @@ | ||
/***/ }), | ||
/* 23 */ | ||
/* 24 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
var Cancel = __webpack_require__(22); | ||
var Cancel = __webpack_require__(23); | ||
@@ -1498,3 +1702,3 @@ /** | ||
/***/ }), | ||
/* 24 */ | ||
/* 25 */ | ||
/***/ (function(module, exports) { | ||
@@ -1529,2 +1733,17 @@ | ||
/***/ }), | ||
/* 26 */ | ||
/***/ (function(module, exports) { | ||
/** | ||
* Determines whether the payload is an error thrown by Axios | ||
* | ||
* @param {*} payload The value to test | ||
* @returns {boolean} True if the payload is an error thrown by Axios, otherwise false | ||
*/ | ||
module.exports = function isAxiosError(payload) { | ||
return (typeof payload === 'object') && (payload.isAxiosError === true); | ||
}; | ||
/***/ }) | ||
@@ -1531,0 +1750,0 @@ /******/ ]) |
{ | ||
"name": "@bundled-es-modules/axios", | ||
"version": "0.18.1", | ||
"version": "0.21.1", | ||
"description": "mirror of axios, bundled and exposed as ES module", | ||
@@ -8,5 +8,5 @@ "author": "Mikhail Bashkirov <bashmish@gmail.com>", | ||
"devDependencies": { | ||
"axios": "0.18.1", | ||
"rollup": "^0.62.0", | ||
"rollup-plugin-commonjs": "^9.1.3" | ||
"@rollup/plugin-commonjs": "^17.0.0", | ||
"axios": "0.21.1", | ||
"rollup": "^2.36.1" | ||
}, | ||
@@ -13,0 +13,0 @@ "scripts": { |
@@ -1,14 +0,12 @@ | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
export default [ | ||
{ | ||
input: './node_modules/axios/dist/axios.js', | ||
input: "./node_modules/axios/dist/axios.js", | ||
output: { | ||
file: './axios.js', | ||
format: 'es', | ||
file: "./axios.js", | ||
format: "es", | ||
}, | ||
plugins: [ | ||
commonjs(), | ||
], | ||
plugins: [commonjs()], | ||
}, | ||
]; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48587
1461
1