2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Releasing 0.8.0

This commit is contained in:
Matt Zabriskie
2015-12-11 12:05:56 -07:00
parent 07b177f347
commit bce07e53aa
8 changed files with 311 additions and 305 deletions
+12
View File
@@ -89,3 +89,15 @@
- Fixing default timeout config for node ([#112](https://github.com/mzabriskie/axios/pull/112)) - 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 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)) - 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
View File
@@ -1,4 +1,4 @@
// Type definitions for Axios v0.7.0 // Type definitions for Axios v0.8.0
// Project: https://github.com/mzabriskie/axios // Project: https://github.com/mzabriskie/axios
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "axios", "name": "axios",
"main": "./dist/axios.js", "main": "./dist/axios.js",
"version": "0.7.0", "version": "0.8.0",
"homepage": "https://github.com/mzabriskie/axios", "homepage": "https://github.com/mzabriskie/axios",
"authors": [ "authors": [
"Matt Zabriskie" "Matt Zabriskie"
+291 -297
View File
@@ -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) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(); module.exports = factory();
@@ -68,7 +68,21 @@ return /******/ (function(modules) { // webpackBootstrap
var dispatchRequest = __webpack_require__(4); var dispatchRequest = __webpack_require__(4);
var InterceptorManager = __webpack_require__(12); 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 // Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') { if (typeof config === 'string') {
config = utils.merge({ config = utils.merge({
@@ -76,13 +90,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, arguments[1]); }, arguments[1]);
} }
config = utils.merge({ config = utils.merge(this.defaultConfig, { method: 'get' }, config);
method: 'get',
headers: {},
timeout: defaults.timeout,
transformRequest: defaults.transformRequest,
transformResponse: defaults.transformResponse
}, config);
// Don't allow overriding defaults.withCredentials // Don't allow overriding defaults.withCredentials
config.withCredentials = config.withCredentials || defaults.withCredentials; config.withCredentials = config.withCredentials || defaults.withCredentials;
@@ -91,11 +99,11 @@ return /******/ (function(modules) { // webpackBootstrap
var chain = [dispatchRequest, undefined]; var chain = [dispatchRequest, undefined];
var promise = Promise.resolve(config); var promise = Promise.resolve(config);
axios.interceptors.request.forEach(function (interceptor) { this.interceptors.request.forEach(function (interceptor) {
chain.unshift(interceptor.fulfilled, interceptor.rejected); chain.unshift(interceptor.fulfilled, interceptor.rejected);
}); });
axios.interceptors.response.forEach(function (interceptor) { this.interceptors.response.forEach(function (interceptor) {
chain.push(interceptor.fulfilled, interceptor.rejected); chain.push(interceptor.fulfilled, interceptor.rejected);
}); });
@@ -106,6 +114,14 @@ return /******/ (function(modules) { // webpackBootstrap
return promise; 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 // Expose defaults
axios.defaults = defaults; axios.defaults = defaults;
@@ -116,39 +132,40 @@ return /******/ (function(modules) { // webpackBootstrap
axios.spread = __webpack_require__(13); axios.spread = __webpack_require__(13);
// Expose interceptors // Expose interceptors
axios.interceptors = { axios.interceptors = defaultInstance.interceptors;
request: new InterceptorManager(),
response: new InterceptorManager() // 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 // Provide aliases for supported request methods
(function () { utils.forEach(['delete', 'get', 'head'], function (method) {
function createShortMethods() { Axios.prototype[method] = function (url, config) {
utils.forEach(arguments, function (method) { return this.request(utils.merge(config || {}, {
axios[method] = function (url, config) { method: method,
return axios(utils.merge(config || {}, { url: url
method: method, }));
url: url };
})); axios[method] = bind(Axios.prototype[method], defaultInstance);
}; });
});
}
function createShortMethodsWithData() { utils.forEach(['post', 'put', 'patch'], function (method) {
utils.forEach(arguments, function (method) { Axios.prototype[method] = function (url, data, config) {
axios[method] = function (url, data, config) { return this.request(utils.merge(config || {}, {
return axios(utils.merge(config || {}, { method: method,
method: method, url: url,
url: url, data: data
data: data }));
})); };
}; axios[method] = bind(Axios.prototype[method], defaultInstance);
}); });
}
createShortMethods('delete', 'get', 'head');
createShortMethodsWithData('post', 'put', 'patch');
})();
/***/ }, /***/ },
@@ -355,16 +372,6 @@ return /******/ (function(modules) { // webpackBootstrap
return str.replace(/^\s*/, '').replace(/\s*$/, ''); 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 * Determine if we're running in a standard browser environment
* *
@@ -376,7 +383,7 @@ return /******/ (function(modules) { // webpackBootstrap
* typeof document -> undefined * typeof document -> undefined
* *
* react-native: * react-native:
* typeof document.createelement -> undefined * typeof document.createElement -> undefined
*/ */
function isStandardBrowserEnv() { function isStandardBrowserEnv() {
return ( return (
@@ -389,7 +396,7 @@ return /******/ (function(modules) { // webpackBootstrap
/** /**
* Iterate over an Array or an Object invoking a function for each item. * 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. * the value, index, and complete array for each item.
* *
* If 'obj' is an Object callback will be called passing * If 'obj' is an Object callback will be called passing
@@ -404,16 +411,13 @@ return /******/ (function(modules) { // webpackBootstrap
return; return;
} }
// Check if obj is array-like
var isArrayLike = isArray(obj) || isArguments(obj);
// Force an array if not already something iterable // Force an array if not already something iterable
if (typeof obj !== 'object' && !isArrayLike) { if (typeof obj !== 'object' && !isArray(obj)) {
obj = [obj]; obj = [obj];
} }
// Iterate over array values // Iterate over array values
if (isArrayLike) { if (isArray(obj)) {
for (var i = 0, l = obj.length; i < l; i++) { for (var i = 0, l = obj.length; i < l; i++) {
fn.call(null, obj[i], i, obj); fn.call(null, obj[i], i, obj);
} }
@@ -447,11 +451,11 @@ return /******/ (function(modules) { // webpackBootstrap
*/ */
function merge(/*obj1, obj2, obj3, ...*/) { function merge(/*obj1, obj2, obj3, ...*/) {
var result = {}; var result = {};
forEach(arguments, function (obj) { var assignValue = function (val, key) { result[key] = val; };
forEach(obj, function (val, key) { var length = arguments.length;
result[key] = val; for (var i = 0; i < length; i++) {
}); forEach(arguments[i], assignValue);
}); }
return result; return result;
} }
@@ -478,7 +482,7 @@ return /******/ (function(modules) { // webpackBootstrap
/* 4 */ /* 4 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {'use strict'; 'use strict';
/** /**
* Dispatch a request to the server using whichever adapter * Dispatch a request to the server using whichever adapter
@@ -492,11 +496,11 @@ return /******/ (function(modules) { // webpackBootstrap
try { try {
// For browsers use XHR adapter // For browsers use XHR adapter
if ((typeof XMLHttpRequest !== 'undefined') || (typeof ActiveXObject !== 'undefined')) { if ((typeof XMLHttpRequest !== 'undefined') || (typeof ActiveXObject !== 'undefined')) {
__webpack_require__(6)(resolve, reject, config); __webpack_require__(5)(resolve, reject, config);
} }
// For node use HTTP adapter // For node use HTTP adapter
else if (typeof process !== 'undefined') { else if (typeof process !== 'undefined') {
__webpack_require__(6)(resolve, reject, config); __webpack_require__(5)(resolve, reject, config);
} }
} catch (e) { } catch (e) {
reject(e); reject(e);
@@ -505,107 +509,9 @@ return /******/ (function(modules) { // webpackBootstrap
}; };
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(5)))
/***/ }, /***/ },
/* 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__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
@@ -614,9 +520,11 @@ return /******/ (function(modules) { // webpackBootstrap
var defaults = __webpack_require__(2); var defaults = __webpack_require__(2);
var utils = __webpack_require__(3); var utils = __webpack_require__(3);
var buildUrl = __webpack_require__(7); var buildURL = __webpack_require__(6);
var parseHeaders = __webpack_require__(8); var parseHeaders = __webpack_require__(7);
var transformData = __webpack_require__(9); var transformData = __webpack_require__(8);
var isURLSameOrigin = __webpack_require__(9);
var btoa = window.btoa || __webpack_require__(10)
module.exports = function xhrAdapter(resolve, reject, config) { module.exports = function xhrAdapter(resolve, reject, config) {
// Transform request data // Transform request data
@@ -637,18 +545,36 @@ return /******/ (function(modules) { // webpackBootstrap
delete requestHeaders['Content-Type']; // Let the browser set it 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 // Create the request
var request = new (XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP'); var request = new adapter('Microsoft.XMLHTTP');
request.open(config.method.toUpperCase(), buildUrl(config.url, config.params), true); request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
// Set the request timeout in MS // Set the request timeout in MS
request.timeout = config.timeout; request.timeout = config.timeout;
// Listen for ready state // Listen for ready state
request.onreadystatechange = function () { request[loadEvent] = function () {
if (request && request.readyState === 4) { if (request && (request.readyState === 4 || xDomain)) {
// Prepare the response // 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 responseData = ['text', ''].indexOf(config.responseType || '') !== -1 ? request.responseText : request.response;
var response = { var response = {
data: transformData( data: transformData(
@@ -661,9 +587,8 @@ return /******/ (function(modules) { // webpackBootstrap
headers: responseHeaders, headers: responseHeaders,
config: config config: config
}; };
// Resolve or reject the Promise based on the status // 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 : resolve :
reject)(response); reject)(response);
@@ -676,11 +601,10 @@ return /******/ (function(modules) { // webpackBootstrap
// This is only done if running in a standard browser environment. // This is only done if running in a standard browser environment.
// Specifically not if we're in a web worker, or react-native. // Specifically not if we're in a web worker, or react-native.
if (utils.isStandardBrowserEnv()) { if (utils.isStandardBrowserEnv()) {
var cookies = __webpack_require__(10); var cookies = __webpack_require__(11);
var urlIsSameOrigin = __webpack_require__(11);
// Add xsrf header // Add xsrf header
var xsrfValue = urlIsSameOrigin(config.url) ? var xsrfValue = isURLSameOrigin(config.url) ?
cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) : cookies.read(config.xsrfCookieName || defaults.xsrfCookieName) :
undefined; undefined;
@@ -690,16 +614,17 @@ return /******/ (function(modules) { // webpackBootstrap
} }
// Add headers to the request // Add headers to the request
utils.forEach(requestHeaders, function (val, key) { if(!xDomain)
// Remove Content-Type if data is undefined utils.forEach(requestHeaders, function (val, key) {
if (!data && key.toLowerCase() === 'content-type') { // Remove Content-Type if data is undefined
delete requestHeaders[key]; if (!data && key.toLowerCase() === 'content-type') {
} delete requestHeaders[key];
// Otherwise add header to the request }
else { // Otherwise add header to the request
request.setRequestHeader(key, val); else {
} request.setRequestHeader(key, val);
}); }
});
// Add withCredentials to request if needed // Add withCredentials to request if needed
if (config.withCredentials) { if (config.withCredentials) {
@@ -727,7 +652,7 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ }, /***/ },
/* 7 */ /* 6 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
@@ -752,47 +677,56 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {object} [params] The params to be appended * @param {object} [params] The params to be appended
* @returns {string} The formatted url * @returns {string} The formatted url
*/ */
module.exports = function buildUrl(url, params) { module.exports = function buildURL(url, params, paramsSerializer) {
if (!params) { if (!params) {
return url; return url;
} }
var parts = []; var serializedParams;
if (paramsSerializer) {
serializedParams = paramsSerializer(params);
}
else {
var parts = [];
utils.forEach(params, function (val, key) { utils.forEach(params, function (val, key) {
if (val === null || typeof val === 'undefined') { if (val === null || typeof val === 'undefined') {
return; 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();
} }
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) { serializedParams = parts.join('&');
url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&'); }
if (serializedParams) {
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
} }
return url; return url;
}; };
/***/ }, /***/ },
/* 8 */ /* 7 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
@@ -832,7 +766,7 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ }, /***/ },
/* 9 */ /* 8 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
@@ -857,53 +791,118 @@ return /******/ (function(modules) { // webpackBootstrap
/***/ }, /***/ },
/* 10 */ /* 9 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; '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 utils = __webpack_require__(3);
module.exports = { module.exports = (
write: function write(name, value, expires, path, domain, secure) { utils.isStandardBrowserEnv() ?
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) { // Standard browser envs have full support of the APIs needed to test
cookie.push('expires=' + new Date(expires).toGMTString()); // 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)) { originURL = resolveURL(window.location.href);
cookie.push('path=' + path);
/**
* 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.');
} }
block = block << 8 | charCode;
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);
} }
return output;
}; };
module.exports = btoa
/***/ }, /***/ },
/* 11 */ /* 11 */
@@ -911,62 +910,57 @@ return /******/ (function(modules) { // webpackBootstrap
'use strict'; '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 utils = __webpack_require__(3);
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originUrl;
/** module.exports = (
* Parse a URL to discover it's components utils.isStandardBrowserEnv() ?
*
* @param {String} url The URL to be parsed
* @returns {Object}
*/
function urlResolve(url) {
var href = url;
if (msie) { // Standard browser envs support document.cookie
// IE needs attribute set twice to normalize properties (function () {
urlParsingNode.setAttribute('href', href); return {
href = urlParsingNode.href; 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 if (utils.isString(path)) {
return { cookie.push('path=' + path);
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 = urlResolve(window.location.href); if (utils.isString(domain)) {
cookie.push('domain=' + domain);
}
/** if (secure === true) {
* Determine if a URL shares the same origin as the current location cookie.push('secure');
* }
* @param {String} requestUrl The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false document.cookie = cookie.join('; ');
*/ },
module.exports = function urlIsSameOrigin(requestUrl) {
var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl; read: function read(name) {
return (parsed.protocol === originUrl.protocol && var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
parsed.host === originUrl.host); 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() {}
};
})()
);
/***/ }, /***/ },
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "axios", "name": "axios",
"version": "0.7.0", "version": "0.8.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",
"scripts": { "scripts": {