@@ -7,62 +7,62 @@ module.exports = (
7
7
8
8
// Standard browser envs have full support of the APIs needed to test
9
9
// whether the request URL is of the same origin as current location.
10
- ( function standardBrowserEnv ( ) {
11
- var msie = / ( m s i e | t r i d e n t ) / i. test ( navigator . userAgent ) ;
12
- var urlParsingNode = document . createElement ( 'a' ) ;
13
- var originURL ;
10
+ ( function standardBrowserEnv ( ) {
11
+ var msie = / ( m s i e | t r i d e n t ) / i. test ( navigator . userAgent ) ;
12
+ var urlParsingNode = document . createElement ( 'a' ) ;
13
+ var originURL ;
14
14
15
- /**
15
+ /**
16
16
* Parse a URL to discover it's components
17
17
*
18
18
* @param {String } url The URL to be parsed
19
19
* @returns {Object }
20
20
*/
21
- function resolveURL ( url ) {
22
- var href = url ;
21
+ function resolveURL ( url ) {
22
+ var href = url ;
23
23
24
- if ( msie ) {
24
+ if ( msie ) {
25
25
// IE needs attribute set twice to normalize properties
26
- urlParsingNode . setAttribute ( 'href' , href ) ;
27
- href = urlParsingNode . href ;
28
- }
26
+ urlParsingNode . setAttribute ( 'href' , href ) ;
27
+ href = urlParsingNode . href ;
28
+ }
29
29
30
- urlParsingNode . setAttribute ( 'href' , href ) ;
30
+ urlParsingNode . setAttribute ( 'href' , href ) ;
31
31
32
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33
- return {
34
- href : urlParsingNode . href ,
35
- protocol : urlParsingNode . protocol ? urlParsingNode . protocol . replace ( / : $ / , '' ) : '' ,
36
- host : urlParsingNode . host ,
37
- search : urlParsingNode . search ? urlParsingNode . search . replace ( / ^ \? / , '' ) : '' ,
38
- hash : urlParsingNode . hash ? urlParsingNode . hash . replace ( / ^ # / , '' ) : '' ,
39
- hostname : urlParsingNode . hostname ,
40
- port : urlParsingNode . port ,
41
- pathname : ( urlParsingNode . pathname . charAt ( 0 ) === '/' ) ?
42
- urlParsingNode . pathname :
43
- '/' + urlParsingNode . pathname
44
- } ;
45
- }
32
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33
+ return {
34
+ href : urlParsingNode . href ,
35
+ protocol : urlParsingNode . protocol ? urlParsingNode . protocol . replace ( / : $ / , '' ) : '' ,
36
+ host : urlParsingNode . host ,
37
+ search : urlParsingNode . search ? urlParsingNode . search . replace ( / ^ \? / , '' ) : '' ,
38
+ hash : urlParsingNode . hash ? urlParsingNode . hash . replace ( / ^ # / , '' ) : '' ,
39
+ hostname : urlParsingNode . hostname ,
40
+ port : urlParsingNode . port ,
41
+ pathname : ( urlParsingNode . pathname . charAt ( 0 ) === '/' ) ?
42
+ urlParsingNode . pathname :
43
+ '/' + urlParsingNode . pathname
44
+ } ;
45
+ }
46
46
47
- originURL = resolveURL ( window . location . href ) ;
47
+ originURL = resolveURL ( window . location . href ) ;
48
48
49
- /**
49
+ /**
50
50
* Determine if a URL shares the same origin as the current location
51
51
*
52
52
* @param {String } requestURL The URL to test
53
53
* @returns {boolean } True if URL shares the same origin, otherwise false
54
54
*/
55
- return function isURLSameOrigin ( requestURL ) {
56
- var parsed = ( utils . isString ( requestURL ) ) ? resolveURL ( requestURL ) : requestURL ;
57
- return ( parsed . protocol === originURL . protocol &&
55
+ return function isURLSameOrigin ( requestURL ) {
56
+ var parsed = ( utils . isString ( requestURL ) ) ? resolveURL ( requestURL ) : requestURL ;
57
+ return ( parsed . protocol === originURL . protocol &&
58
58
parsed . host === originURL . host ) ;
59
- } ;
60
- } ) ( ) :
59
+ } ;
60
+ } ) ( ) :
61
61
62
62
// Non standard browser envs (web workers, react-native) lack needed support.
63
- ( function nonStandardBrowserEnv ( ) {
64
- return function isURLSameOrigin ( ) {
65
- return true ;
66
- } ;
67
- } ) ( )
63
+ ( function nonStandardBrowserEnv ( ) {
64
+ return function isURLSameOrigin ( ) {
65
+ return true ;
66
+ } ;
67
+ } ) ( )
68
68
) ;
0 commit comments