function urlsAreSameOrigin(url1, url2) {
  const parsedUrl1 = resolveURL(url1);
  const parsedUrl2 = resolveURL(url2);

  return parsedUrl1.protocol === parsedUrl2.protocol && parsedUrl1.host === parsedUrl2.host;
}
Determine if two URLs share the same origin.

@param {string | {protocol: string, host: string }} url1 - First URL to compare as a string or a normalized URL
@param {string | {protocol: string, host: string }} url2 - Second URL to compare as a string or a normalized URL

@returns {boolean} - true if both URLs have the same origin, and false otherwise.