Hacker News new | ask | show | jobs
by toomanybeersies 1725 days ago
If you're writing browser JS, just use the URL builtin

  const isValidUrl = urlString => {
    try {
      new URL(urlString);
      return true;
    } catch {
      return false;
    }
  };