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
+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);
};
};