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

Adding ESLint

This commit is contained in:
mzabriskie
2015-03-17 14:14:26 -06:00
parent 7387829d33
commit a98c61f458
17 changed files with 128 additions and 77 deletions
+2 -2
View File
@@ -1,8 +1,7 @@
'use strict';
var utils = require('./../utils');
function encode(val) {
'use strict';
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
@@ -19,6 +18,7 @@ function encode(val) {
* @returns {string} The formatted url
*/
module.exports = function buildUrl(url, params) {
'use strict';
if (!params) {
return url;
}
+4 -3
View File
@@ -1,9 +1,8 @@
'use strict';
var utils = require('./../utils');
module.exports = {
write: function write(name, value, expires, path, domain, secure) {
'use strict';
var cookie = [];
cookie.push(name + '=' + encodeURIComponent(value));
@@ -27,11 +26,13 @@ module.exports = {
},
read: function read(name) {
'use strict';
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : null);
},
remove: function remove(name) {
'use strict';
this.write(name, '', Date.now() - 86400000);
}
};
};
+3 -2
View File
@@ -1,5 +1,3 @@
'use strict';
/**
* Supply a warning to the developer that a method they are using
* has been deprecated.
@@ -9,6 +7,9 @@
* @param {string} [docs] The documentation URL to get further details
*/
module.exports = function deprecatedMethod(method, instead, docs) {
/*eslint-env node*/
'use strict';
try {
console.warn(
'DEPRECATED method `' + method + '`.' +
+3 -4
View File
@@ -1,5 +1,3 @@
'use strict';
var utils = require('./../utils');
/**
@@ -16,9 +14,10 @@ var utils = require('./../utils');
* @returns {Object} Headers parsed into an object
*/
module.exports = function parseHeaders(headers) {
'use strict';
var parsed = {}, key, val, i;
if (!headers) return parsed;
if (!headers) { return parsed; }
utils.forEach(headers.split('\n'), function(line) {
i = line.indexOf(':');
@@ -31,4 +30,4 @@ module.exports = function parseHeaders(headers) {
});
return parsed;
};
};
+2 -1
View File
@@ -19,7 +19,8 @@
* @returns {Function}
*/
module.exports = function spread(callback) {
'use strict';
return function (arr) {
callback.apply(null, arr);
};
};
};
+2 -3
View File
@@ -1,5 +1,3 @@
'use strict';
var utils = require('./../utils');
/**
@@ -11,9 +9,10 @@ var utils = require('./../utils');
* @returns {*} The resulting transformed data
*/
module.exports = function transformData(data, headers, fns) {
'use strict';
utils.forEach(fns, function (fn) {
data = fn(data, headers);
});
return data;
};
};
+10 -8
View File
@@ -1,9 +1,7 @@
'use strict';
var msie = /(msie|trident)/i.test(navigator.userAgent);
var utils = require('./../utils');
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement('a');
var originUrl = urlResolve(window.location.href);
var originUrl;
/**
* Parse a URL to discover it's components
@@ -12,6 +10,7 @@ var originUrl = urlResolve(window.location.href);
* @returns {Object}
*/
function urlResolve(url) {
'use strict';
var href = url;
if (msie) {
@@ -31,12 +30,14 @@ function urlResolve(url) {
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/')
? urlParsingNode.pathname
: '/' + urlParsingNode.pathname
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname :
'/' + urlParsingNode.pathname
};
}
originUrl = urlResolve(window.location.href);
/**
* Determine if a URL shares the same origin as the current location
*
@@ -44,7 +45,8 @@ function urlResolve(url) {
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
module.exports = function urlIsSameOrigin(requestUrl) {
'use strict';
var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
return (parsed.protocol === originUrl.protocol &&
parsed.host === originUrl.host);
};
};