function isLocal(url) {
  const locationOrigin = getLocationOrigin();
  const resolved = new URL(url, locationOrigin);
  return resolved.origin === locationOrigin;
}
Detects whether a given url is from the same origin as the current page (browser only).