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

chore: upgrade eslint and add fix command

This commit is contained in:
Justin Beckwith
2018-04-06 21:50:20 -07:00
parent 0d110da98c
commit 22c2baf205
4 changed files with 83 additions and 82 deletions
+2 -2
View File
@@ -119,8 +119,8 @@ module.exports = function xhrAdapter(config) {
// Add xsrf header // Add xsrf header
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ? var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
cookies.read(config.xsrfCookieName) : cookies.read(config.xsrfCookieName) :
undefined; undefined;
if (xsrfValue) { if (xsrfValue) {
requestHeaders[config.xsrfHeaderName] = xsrfValue; requestHeaders[config.xsrfHeaderName] = xsrfValue;
+40 -40
View File
@@ -6,48 +6,48 @@ module.exports = (
utils.isStandardBrowserEnv() ? utils.isStandardBrowserEnv() ?
// Standard browser envs support document.cookie // Standard browser envs support document.cookie
(function standardBrowserEnv() { (function standardBrowserEnv() {
return { return {
write: function write(name, value, expires, path, domain, secure) { write: function write(name, value, expires, path, domain, secure) {
var cookie = []; var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value)); cookie.push(name + '=' + encodeURIComponent(value));
if (utils.isNumber(expires)) { if (utils.isNumber(expires)) {
cookie.push('expires=' + new Date(expires).toGMTString()); 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);
} }
};
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. // Non standard browser env (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() { (function nonStandardBrowserEnv() {
return { return {
write: function write() {}, write: function write() {},
read: function read() { return null; }, read: function read() { return null; },
remove: function remove() {} remove: function remove() {}
}; };
})() })()
); );
+38 -38
View File
@@ -7,62 +7,62 @@ module.exports = (
// Standard browser envs have full support of the APIs needed to test // Standard browser envs have full support of the APIs needed to test
// whether the request URL is of the same origin as current location. // whether the request URL is of the same origin as current location.
(function standardBrowserEnv() { (function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent); var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a'); var urlParsingNode = document.createElement('a');
var originURL; var originURL;
/** /**
* Parse a URL to discover it's components * Parse a URL to discover it's components
* *
* @param {String} url The URL to be parsed * @param {String} url The URL to be parsed
* @returns {Object} * @returns {Object}
*/ */
function resolveURL(url) { function resolveURL(url) {
var href = url; var href = url;
if (msie) { if (msie) {
// IE needs attribute set twice to normalize properties // IE needs attribute set twice to normalize properties
urlParsingNode.setAttribute('href', href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', 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 * Determine if a URL shares the same origin as the current location
* *
* @param {String} requestURL The URL to test * @param {String} requestURL The URL to test
* @returns {boolean} True if URL shares the same origin, otherwise false * @returns {boolean} True if URL shares the same origin, otherwise false
*/ */
return function isURLSameOrigin(requestURL) { return function isURLSameOrigin(requestURL) {
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol && return (parsed.protocol === originURL.protocol &&
parsed.host === originURL.host); parsed.host === originURL.host);
}; };
})() : })() :
// Non standard browser envs (web workers, react-native) lack needed support. // Non standard browser envs (web workers, react-native) lack needed support.
(function nonStandardBrowserEnv() { (function nonStandardBrowserEnv() {
return function isURLSameOrigin() { return function isURLSameOrigin() {
return true; return true;
}; };
})() })()
); );
+3 -2
View File
@@ -11,7 +11,8 @@
"version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json", "version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
"postversion": "git push && git push --tags", "postversion": "git push && git push --tags",
"examples": "node ./examples/server.js", "examples": "node ./examples/server.js",
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"fix": "eslint --fix lib/**/*.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -40,7 +41,7 @@
"grunt-contrib-clean": "^1.1.0", "grunt-contrib-clean": "^1.1.0",
"grunt-contrib-nodeunit": "^1.0.0", "grunt-contrib-nodeunit": "^1.0.0",
"grunt-contrib-watch": "^1.0.0", "grunt-contrib-watch": "^1.0.0",
"grunt-eslint": "^19.0.0", "grunt-eslint": "^20.1.0",
"grunt-karma": "^2.0.0", "grunt-karma": "^2.0.0",
"grunt-ts": "^6.0.0-beta.19", "grunt-ts": "^6.0.0-beta.19",
"grunt-webpack": "^1.0.18", "grunt-webpack": "^1.0.18",