mirror of
https://github.com/tenrok/axios.git
synced 2026-05-30 15:24:11 +03:00
Releasing 0.8.0
This commit is contained in:
@@ -89,3 +89,15 @@
|
||||
- Fixing default timeout config for node ([#112](https://github.com/mzabriskie/axios/pull/112))
|
||||
- Adding support for use in web workers, and react-native ([#70](https://github.com/mzabriskie/axios/issue/70)), ([#98](https://github.com/mzabriskie/axios/pull/98))
|
||||
- Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/mzabriskie/axios/issues/116))
|
||||
|
||||
### 0.8.0 (Dec 11, 2015)
|
||||
|
||||
- Adding support for creating instances of axios ([#123](https://github.com/mzabriskie/axios/pull/123))
|
||||
- Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/mzabriskie/axios/pull/128))
|
||||
- Adding support for using custom parameter serializer with `paramsSerializer` option ([#121](https://github.com/mzabriskie/axios/pull/121))
|
||||
- Fixing issue in IE8 caused by `forEach` on `arguments` ([#127](https://github.com/mzabriskie/axios/pull/127))
|
||||
- Adding support for following redirects in node ([#146](https://github.com/mzabriskie/axios/pull/146))
|
||||
- Adding support for transparent decompression if `content-encoding` is set ([#149](https://github.com/mzabriskie/axios/pull/149))
|
||||
- Adding support for transparent XDomainRequest to handle cross domain requests in IE9 ([#140](https://github.com/mzabriskie/axios/pull/140))
|
||||
- Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/mzabriskie/axios/pull/167))
|
||||
- Adding support for baseURL option ([#160](https://github.com/mzabriskie/axios/pull/160))
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Axios v0.7.0
|
||||
// Type definitions for Axios v0.8.0
|
||||
// Project: https://github.com/mzabriskie/axios
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"main": "./dist/axios.js",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"homepage": "https://github.com/mzabriskie/axios",
|
||||
"authors": [
|
||||
"Matt Zabriskie"
|
||||
|
||||
Vendored
+292
-298
@@ -1,4 +1,4 @@
|
||||
/* axios v0.7.0 | (c) 2015 by Matt Zabriskie */
|
||||
/* axios v0.8.0 | (c) 2015 by Matt Zabriskie */
|
||||
(function webpackUniversalModuleDefinition(root, factory) {
|
||||
if(typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = factory();
|
||||
@@ -68,7 +68,21 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
var dispatchRequest = __webpack_require__(4);
|
||||
var InterceptorManager = __webpack_require__(12);
|
||||
|
||||
var axios = module.exports = function (config) {
|
||||
function Axios (defaultConfig) {
|
||||
this.defaultConfig = utils.merge({
|
||||
headers: {},
|
||||
timeout: defaults.timeout,
|
||||
transformRequest: defaults.transformRequest,
|
||||
transformResponse: defaults.transformResponse
|
||||
}, defaultConfig);
|
||||
|
||||
this.interceptors = {
|
||||
request: new InterceptorManager(),
|
||||
response: new InterceptorManager()
|
||||
};
|
||||
}
|
||||
|
||||
Axios.prototype.request = function (config) {
|
||||
// Allow for axios('example/url'[, config]) a la fetch API
|
||||
if (typeof config === 'string') {
|
||||
config = utils.merge({
|
||||
@@ -76,13 +90,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
}, arguments[1]);
|
||||
}
|
||||
|
||||
config = utils.merge({
|
||||
method: 'get',
|
||||
headers: {},
|
||||
timeout: defaults.timeout,
|
||||
transformRequest: defaults.transformRequest,
|
||||
transformResponse: defaults.transformResponse
|
||||
}, config);
|
||||
config = utils.merge(this.defaultConfig, { method: 'get' }, config);
|
||||
|
||||
// Don't allow overriding defaults.withCredentials
|
||||
config.withCredentials = config.withCredentials || defaults.withCredentials;
|
||||
@@ -91,11 +99,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
var chain = [dispatchRequest, undefined];
|
||||
var promise = Promise.resolve(config);
|
||||
|
||||
axios.interceptors.request.forEach(function (interceptor) {
|
||||
this.interceptors.request.forEach(function (interceptor) {
|
||||
chain.unshift(interceptor.fulfilled, interceptor.rejected);
|
||||
});
|
||||
|
||||
axios.interceptors.response.forEach(function (interceptor) {
|
||||
this.interceptors.response.forEach(function (interceptor) {
|
||||
chain.push(interceptor.fulfilled, interceptor.rejected);
|
||||
});
|
||||
|
||||
@@ -106,6 +114,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
return promise;
|
||||
};
|
||||
|
||||
var defaultInstance = new Axios();
|
||||
|
||||
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
|
||||
|
||||
axios.create = function (defaultConfig) {
|
||||
return new Axios(defaultConfig);
|
||||
};
|
||||
|
||||
// Expose defaults
|
||||
axios.defaults = defaults;
|
||||
|
||||
@@ -116,39 +132,40 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
axios.spread = __webpack_require__(13);
|
||||
|
||||
// Expose interceptors
|
||||
axios.interceptors = {
|
||||
request: new InterceptorManager(),
|
||||
response: new InterceptorManager()
|
||||
};
|
||||
axios.interceptors = defaultInstance.interceptors;
|
||||
|
||||
// Helpers
|
||||
function bind (fn, thisArg) {
|
||||
return function () {
|
||||
var args = new Array(arguments.length);
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
return fn.apply(thisArg, args);
|
||||
};
|
||||
}
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
(function () {
|
||||
function createShortMethods() {
|
||||
utils.forEach(arguments, function (method) {
|
||||
axios[method] = function (url, config) {
|
||||
return axios(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url
|
||||
}));
|
||||
};
|
||||
});
|
||||
}
|
||||
utils.forEach(['delete', 'get', 'head'], function (method) {
|
||||
Axios.prototype[method] = function (url, config) {
|
||||
return this.request(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url
|
||||
}));
|
||||
};
|
||||
axios[method] = bind(Axios.prototype[method], defaultInstance);
|
||||
});
|
||||
|
||||
function createShortMethodsWithData() {
|
||||
utils.forEach(arguments, function (method) {
|
||||
axios[method] = function (url, data, config) {
|
||||
return axios(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url,
|
||||
data: data
|
||||
}));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
createShortMethods('delete', 'get', 'head');
|
||||
createShortMethodsWithData('post', 'put', 'patch');
|
||||
})();
|
||||
utils.forEach(['post', 'put', 'patch'], function (method) {
|
||||
Axios.prototype[method] = function (url, data, config) {
|
||||
return this.request(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url,
|
||||
data: data
|
||||
}));
|
||||
};
|
||||
axios[method] = bind(Axios.prototype[method], defaultInstance);
|
||||
});
|
||||
|
||||
|
||||
/***/ },
|
||||
@@ -355,16 +372,6 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an Arguments object
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Arguments object, otherwise false
|
||||
*/
|
||||
function isArguments(val) {
|
||||
return toString.call(val) === '[object Arguments]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we're running in a standard browser environment
|
||||
*
|
||||
@@ -376,7 +383,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
* typeof document -> undefined
|
||||
*
|
||||
* react-native:
|
||||
* typeof document.createelement -> undefined
|
||||
* typeof document.createElement -> undefined
|
||||
*/
|
||||
function isStandardBrowserEnv() {
|
||||
return (
|
||||
@@ -389,7 +396,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
* If `obj` is an Array or arguments callback will be called passing
|
||||
* If `obj` is an Array callback will be called passing
|
||||
* the value, index, and complete array for each item.
|
||||
*
|
||||
* If 'obj' is an Object callback will be called passing
|
||||
@@ -404,16 +411,13 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if obj is array-like
|
||||
var isArrayLike = isArray(obj) || isArguments(obj);
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== 'object' && !isArrayLike) {
|
||||
if (typeof obj !== 'object' && !isArray(obj)) {
|
||||
obj = [obj];
|
||||
}
|
||||
|
||||
// Iterate over array values
|
||||
if (isArrayLike) {
|
||||
if (isArray(obj)) {
|
||||
for (var i = 0, l = obj.length; i < l; i++) {
|
||||
fn.call(null, obj[i], i, obj);
|
||||
}
|
||||
@@ -447,11 +451,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
*/
|
||||
function merge(/*obj1, obj2, obj3, ...*/) {
|
||||
var result = {};
|
||||
forEach(arguments, function (obj) {
|
||||
forEach(obj, function (val, key) {
|
||||
result[key] = val;
|
||||
});
|
||||
});
|
||||
var assignValue = function (val, key) { result[key] = val; };
|
||||
var length = arguments.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
forEach(arguments[i], assignValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -478,7 +482,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
/* 4 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(process) {'use strict';
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Dispatch a request to the server using whichever adapter
|
||||
@@ -492,11 +496,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
try {
|
||||
// For browsers use XHR adapter
|
||||
if ((typeof XMLHttpRequest !== 'undefined') || (typeof ActiveXObject !== 'undefined')) {
|
||||
__webpack_require__(6)(resolve, reject, config);
|
||||
__webpack_require__(5)(resolve, reject, config);
|
||||
}
|
||||
// For node use HTTP adapter
|
||||
else if (typeof process !== 'undefined') {
|
||||
__webpack_require__(6)(resolve, reject, config);
|
||||
__webpack_require__(5)(resolve, reject, config);
|
||||
}
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
@@ -504,108 +508,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 5 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
// shim for using process in browser
|
||||
|
||||
var process = module.exports = {};
|
||||
var queue = [];
|
||||
var draining = false;
|
||||
var currentQueue;
|
||||
var queueIndex = -1;
|
||||
|
||||
function cleanUpNextTick() {
|
||||
draining = false;
|
||||
if (currentQueue.length) {
|
||||
queue = currentQueue.concat(queue);
|
||||
} else {
|
||||
queueIndex = -1;
|
||||
}
|
||||
if (queue.length) {
|
||||
drainQueue();
|
||||
}
|
||||
}
|
||||
|
||||
function drainQueue() {
|
||||
if (draining) {
|
||||
return;
|
||||
}
|
||||
var timeout = setTimeout(cleanUpNextTick);
|
||||
draining = true;
|
||||
|
||||
var len = queue.length;
|
||||
while(len) {
|
||||
currentQueue = queue;
|
||||
queue = [];
|
||||
while (++queueIndex < len) {
|
||||
if (currentQueue) {
|
||||
currentQueue[queueIndex].run();
|
||||
}
|
||||
}
|
||||
queueIndex = -1;
|
||||
len = queue.length;
|
||||
}
|
||||
currentQueue = null;
|
||||
draining = false;
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
process.nextTick = function (fun) {
|
||||
var args = new Array(arguments.length - 1);
|
||||
if (arguments.length > 1) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
args[i - 1] = arguments[i];
|
||||
}
|
||||
}
|
||||
queue.push(new Item(fun, args));
|
||||
if (queue.length === 1 && !draining) {
|
||||
setTimeout(drainQueue, 0);
|
||||
}
|
||||
};
|
||||
|
||||
// v8 likes predictible objects
|
||||
function Item(fun, array) {
|
||||
this.fun = fun;
|
||||
this.array = array;
|
||||
}
|
||||
Item.prototype.run = function () {
|
||||
this.fun.apply(null, this.array);
|
||||
};
|
||||
process.title = 'browser';
|
||||
process.browser = true;
|
||||
process.env = {};
|
||||
process.argv = [];
|
||||
process.version = ''; // empty string to avoid regexp issues
|
||||
process.versions = {};
|
||||
|
||||
function noop() {}
|
||||
|
||||
process.on = noop;
|
||||
process.addListener = noop;
|
||||
process.once = noop;
|
||||
process.off = noop;
|
||||
process.removeListener = noop;
|
||||
process.removeAllListeners = noop;
|
||||
process.emit = noop;
|
||||
|
||||
process.binding = function (name) {
|
||||
throw new Error('process.binding is not supported');
|
||||
};
|
||||
|
||||
process.cwd = function () { return '/' };
|
||||
process.chdir = function (dir) {
|
||||
throw new Error('process.chdir is not supported');
|
||||
};
|
||||
process.umask = function() { return 0; };
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
@@ -614,9 +520,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
|
||||
var defaults = __webpack_require__(2);
|
||||
var utils = __webpack_require__(3);
|
||||
var buildUrl = __webpack_require__(7);
|
||||
var parseHeaders = __webpack_require__(8);
|
||||
var transformData = __webpack_require__(9);
|
||||
var buildURL = __webpack_require__(6);
|
||||
var parseHeaders = __webpack_require__(7);
|
||||
var transformData = __webpack_require__(8);
|
||||
var isURLSameOrigin = __webpack_require__(9);
|
||||
var btoa = window.btoa || __webpack_require__(10)
|
||||
|
||||
module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
// Transform request data
|
||||
@@ -637,18 +545,36 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
delete requestHeaders['Content-Type']; // Let the browser set it
|
||||
}
|
||||
|
||||
var adapter = (XMLHttpRequest || ActiveXObject);
|
||||
var loadEvent = 'onreadystatechange';
|
||||
var xDomain = false;
|
||||
|
||||
// For IE 8/9 CORS support
|
||||
if(!isURLSameOrigin(config.url) && window.XDomainRequest){
|
||||
adapter = window.XDomainRequest;
|
||||
loadEvent = 'onload';
|
||||
xDomain = true;
|
||||
}
|
||||
|
||||
// HTTP basic authentication
|
||||
if (config.auth) {
|
||||
var username = config.auth.username || '';
|
||||
var password = config.auth.password || '';
|
||||
requestHeaders['Authorization'] = 'Basic: ' + btoa(username + ':' + password);
|
||||
}
|
||||
|
||||
// Create the request
|
||||
var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
||||
request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true);
|
||||
var request = new adapter('Microsoft.XMLHTTP');
|
||||
request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
|
||||
|
||||
// Set the request timeout in MS
|
||||
request.timeout = config.timeout;
|
||||
|
||||
// Listen for ready state
|
||||
request.onreadystatechange = function () {
|
||||
if (request && request.readyState === 4) {
|
||||
request[loadEvent] = function () {
|
||||
if (request && (request.readyState === 4 || xDomain)) {
|
||||
// Prepare the response
|
||||
var responseHeaders = parseHeaders(request.getAllResponseHeaders());
|
||||
var responseHeaders = xDomain ? null : parseHeaders(request.getAllResponseHeaders());
|
||||
var responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response;
|
||||
var response = {
|
||||
data: transformData(
|
||||
@@ -661,9 +587,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
headers: responseHeaders,
|
||||
config: config
|
||||
};
|
||||
|
||||
// Resolve or reject the Promise based on the status
|
||||
(request.status >= 200 && request.status < 300 ?
|
||||
((request.status >= 200 && request.status < 300) || (request.responseText && xDomain) ?
|
||||
resolve :
|
||||
reject)(response);
|
||||
|
||||
@@ -676,11 +601,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
// This is only done if running in a standard browser environment.
|
||||
// Specifically not if we're in a web worker, or react-native.
|
||||
if (utils.isStandardBrowserEnv()) {
|
||||
var cookies = __webpack_require__(10);
|
||||
var urlIsSameOrigin = __webpack_require__(11);
|
||||
var cookies = __webpack_require__(11);
|
||||
|
||||
// Add xsrf header
|
||||
var xsrfValue = urlIsSameOrigin(config.url) ?
|
||||
var xsrfValue = isURLSameOrigin(config.url) ?
|
||||
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :
|
||||
undefined;
|
||||
|
||||
@@ -690,16 +614,17 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
}
|
||||
|
||||
// Add headers to the request
|
||||
utils.forEach(requestHeaders, function (val, key) {
|
||||
// Remove Content-Type if data is undefined
|
||||
if (!data && key.toLowerCase() === 'content-type') {
|
||||
delete requestHeaders[key];
|
||||
}
|
||||
// Otherwise add header to the request
|
||||
else {
|
||||
request.setRequestHeader(key, val);
|
||||
}
|
||||
});
|
||||
if(!xDomain)
|
||||
utils.forEach(requestHeaders, function (val, key) {
|
||||
// Remove Content-Type if data is undefined
|
||||
if (!data && key.toLowerCase() === 'content-type') {
|
||||
delete requestHeaders[key];
|
||||
}
|
||||
// Otherwise add header to the request
|
||||
else {
|
||||
request.setRequestHeader(key, val);
|
||||
}
|
||||
});
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (config.withCredentials) {
|
||||
@@ -727,7 +652,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
@@ -752,47 +677,56 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
* @param {object} [params] The params to be appended
|
||||
* @returns {string} The formatted url
|
||||
*/
|
||||
module.exports = function buildUrl(url, params) {
|
||||
module.exports = function buildURL(url, params, paramsSerializer) {
|
||||
if (!params) {
|
||||
return url;
|
||||
}
|
||||
|
||||
var parts = [];
|
||||
var serializedParams;
|
||||
if (paramsSerializer) {
|
||||
serializedParams = paramsSerializer(params);
|
||||
}
|
||||
else {
|
||||
var parts = [];
|
||||
|
||||
utils.forEach(params, function (val, key) {
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (utils.isArray(val)) {
|
||||
key = key + '[]';
|
||||
}
|
||||
|
||||
if (!utils.isArray(val)) {
|
||||
val = [val];
|
||||
}
|
||||
|
||||
utils.forEach(val, function (v) {
|
||||
if (utils.isDate(v)) {
|
||||
v = v.toISOString();
|
||||
utils.forEach(params, function (val, key) {
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return;
|
||||
}
|
||||
else if (utils.isObject(v)) {
|
||||
v = JSON.stringify(v);
|
||||
|
||||
if (utils.isArray(val)) {
|
||||
key = key + '[]';
|
||||
}
|
||||
parts.push(encode(key) + '=' + encode(v));
|
||||
|
||||
if (!utils.isArray(val)) {
|
||||
val = [val];
|
||||
}
|
||||
|
||||
utils.forEach(val, function (v) {
|
||||
if (utils.isDate(v)) {
|
||||
v = v.toISOString();
|
||||
}
|
||||
else if (utils.isObject(v)) {
|
||||
v = JSON.stringify(v);
|
||||
}
|
||||
parts.push(encode(key) + '=' + encode(v));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (parts.length > 0) {
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&');
|
||||
serializedParams = parts.join('&');
|
||||
}
|
||||
|
||||
if (serializedParams) {
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 8 */
|
||||
/* 7 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
@@ -832,7 +766,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 9 */
|
||||
/* 8 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
@@ -857,52 +791,117 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 10 */
|
||||
/* 9 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* WARNING:
|
||||
* This file makes references to objects that aren't safe in all environments.
|
||||
* Please see lib/utils.isStandardBrowserEnv before including this file.
|
||||
*/
|
||||
|
||||
var utils = __webpack_require__(3);
|
||||
|
||||
module.exports = {
|
||||
write: function write(name, value, expires, path, domain, secure) {
|
||||
var cookie = [];
|
||||
cookie.push(name + '=' + encodeURIComponent(value));
|
||||
module.exports = (
|
||||
utils.isStandardBrowserEnv() ?
|
||||
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||
// 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 () {
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
if (utils.isString(path)) {
|
||||
cookie.push('path=' + path);
|
||||
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 () {
|
||||
return function isURLSameOrigin() {
|
||||
return true;
|
||||
};
|
||||
})()
|
||||
);
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 10 */
|
||||
/***/ function(module, exports) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
|
||||
|
||||
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
|
||||
function InvalidCharacterError(message) {
|
||||
this.message = message;
|
||||
}
|
||||
InvalidCharacterError.prototype = new Error;
|
||||
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
||||
|
||||
function btoa (input) {
|
||||
var str = String(input);
|
||||
for (
|
||||
// initialize result and counter
|
||||
var block, charCode, idx = 0, map = chars, output = '';
|
||||
// if the next str index does not exist:
|
||||
// change the mapping table to "="
|
||||
// check if d has no fractional digits
|
||||
str.charAt(idx | 0) || (map = '=', idx % 1);
|
||||
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
||||
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
||||
) {
|
||||
charCode = str.charCodeAt(idx += 3/4);
|
||||
if (charCode > 0xFF) {
|
||||
throw new InvalidCharacterError('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
|
||||
}
|
||||
|
||||
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);
|
||||
block = block << 8 | charCode;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
module.exports = btoa
|
||||
|
||||
|
||||
/***/ },
|
||||
@@ -911,62 +910,57 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* WARNING:
|
||||
* This file makes references to objects that aren't safe in all environments.
|
||||
* Please see lib/utils.isStandardBrowserEnv before including this file.
|
||||
*/
|
||||
|
||||
var utils = __webpack_require__(3);
|
||||
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 urlResolve(url) {
|
||||
var href = url;
|
||||
module.exports = (
|
||||
utils.isStandardBrowserEnv() ?
|
||||
|
||||
if (msie) {
|
||||
// IE needs attribute set twice to normalize properties
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
href = urlParsingNode.href;
|
||||
}
|
||||
// Standard browser envs support document.cookie
|
||||
(function () {
|
||||
return {
|
||||
write: function write(name, value, expires, path, domain, secure) {
|
||||
var cookie = [];
|
||||
cookie.push(name + '=' + encodeURIComponent(value));
|
||||
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||
}
|
||||
|
||||
// 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
|
||||
};
|
||||
}
|
||||
if (utils.isString(path)) {
|
||||
cookie.push('path=' + path);
|
||||
}
|
||||
|
||||
originUrl = urlResolve(window.location.href);
|
||||
if (utils.isString(domain)) {
|
||||
cookie.push('domain=' + domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
module.exports = function urlIsSameOrigin(requestUrl) {
|
||||
var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
|
||||
return (parsed.protocol === originUrl.protocol &&
|
||||
parsed.host === originUrl.host);
|
||||
};
|
||||
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 () {
|
||||
return {
|
||||
write: function write() {},
|
||||
read: function read() { return null; },
|
||||
remove: function remove() {}
|
||||
};
|
||||
})()
|
||||
);
|
||||
|
||||
|
||||
/***/ },
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
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
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"version": "0.7.0",
|
||||
"version": "0.8.0",
|
||||
"description": "Promise based HTTP client for the browser and node.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user