const sameHost = (parent, child) => {
  const p = new URL (parent);
  const c = new URL (child);
  return p.host === c.host || c.host.endsWith ('.' + p.host);
};
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.