function checkSameOrigin(url1, url2) {
  const parsed1 = new URL(url1);
  const parsed2 = new URL(url2);

  return parsed1.origin === parsed2.origin;
}
Returns whether the urls are of the same origin. See https://html.spec.whatwg.org/#same-origin
@param {string} url1
@param {string} url2
@return {boolean}