function isURLTrustedOrSameOrigin(requestURL, xsrfTrustedOrigins) {
  const parsed = typeof requestURL === 'string' ? resolveURL(requestURL) : requestURL;
  const originURL = resolveURL(window.location.href);
  const parsedAllowedOriginUrls = [originURL].concat(xsrfTrustedOrigins.map(resolveURL));

  return parsedAllowedOriginUrls.some(urlsAreSameOrigin.bind(null, parsed));
}
Check if the URL provided has the same origin as the one used.
Or if it is for a trusted XSRF origin.

@param {String} requestURL The requestedURL
@param {string[]} xsrfTrustedOrigins List of allowed origins
@returns {boolean} true if it is the same origin, else false