function updateUrlHash(url, hash, allowRel = false) {
  const res = URL.parse(url);
  if (res) {
    res.hash = hash;
    return res.href;
  }
  // Support well-formed relative URLs, necessary for `web/app.js` in GENERIC
  // builds, by optionally falling back to string parsing.
  if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
    return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
  }
  return "";
}
Remove, or replace, the hash property of the URL.

@param {URL|string} url - The absolute, or relative, URL.
@param {string} hash - The hash property (use an empty string to remove it).
@param {boolean} [allowRel] - Allow relative URLs.
@returns {string} The resulting URL string.