@@ -98,7 +98,7 @@ function urlIsSameOrigin(requestUrl) {
98
98
* Parse a request URL and determine whether it is same-origin as the current document base URL.
99
99
*
100
100
* Note: The base URL is usually the same the document location (`location.href`) but can
101
- * overriden by using the `<base>` tag.
101
+ * be overriden by using the `<base>` tag.
102
102
*
103
103
* @param {string|object } requestUrl The url of the request as a string that will be resolved
104
104
* or a parsed URL object.
@@ -113,18 +113,18 @@ function urlIsSameOriginAsBaseUrl(requestUrl) {
113
113
/**
114
114
* Determines if two URLs share the same origin.
115
115
*
116
- * @param {object } url1 First URL to compare. Must be a normalized URL in the form of a
117
- * dictionary object returned by `urlResolve()`.
118
- * @param {object } url2 Second URL to compare. Must be a normalized URL in the form of a
119
- * dictionary object returned by `urlResolve()`.
116
+ * @param {string| object } url1 First URL to compare as a string or a normalized URL in the form of
117
+ * a dictionary object returned by `urlResolve()`.
118
+ * @param {string| object } url2 Second URL to compare as a string or a normalized URL in the form of
119
+ * a dictionary object returned by `urlResolve()`.
120
120
* @return {boolean } True if both URLs have the same origin, and false otherwise.
121
121
*/
122
122
function urlsAreSameOrigin ( url1 , url2 ) {
123
- // IE sometimes includes a port in the 'host' property, even if it is the default 80 port so
124
- // we check hostname and port separately.
125
- return url1 . protocol === url2 . protocol &&
126
- url1 . hostname === url2 . hostname &&
127
- url1 . port === url2 . port ;
123
+ url1 = ( isString ( url1 ) ) ? urlResolve ( url1 ) : url1 ;
124
+ url2 = ( isString ( url2 ) ) ? urlResolve ( url2 ) : url2 ;
125
+
126
+ return ( url1 . protocol === url2 . protocol &&
127
+ url1 . host === url2 . host ) ;
128
128
}
129
129
130
130
/**
0 commit comments