Skip to content

Commit

Permalink
fix(helpers): handles improper inputs gracefully in isURLSameOrigin
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbhesswebber committed Oct 15, 2022
1 parent 4777b7a commit 61c1bb1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/helpers/isURLSameOrigin.js
Expand Up @@ -53,9 +53,20 @@ export default platform.isStandardBrowserEnv ?
* @returns {boolean} True if URL shares the same origin, otherwise false
*/
return function isURLSameOrigin(requestURL) {
const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
return (parsed.protocol === originURL.protocol &&
parsed.host === originURL.host);
if (
!requestURL ||
(!utils.isString(requestURL) &&
!(
Object.prototype.hasOwnProperty.call(requestURL, "protocol") &&
Object.prototype.hasOwnProperty.call(requestURL, "host")
))
) {
return utils.isString(requestURL) ? requestURL : typeof requestURL;
}
const parsed = resolveURL(requestURL);
return (
parsed.protocol === originURL.protocol && parsed.host === originURL.host
);
};
})() :

Expand Down

0 comments on commit 61c1bb1

Please sign in to comment.