Function isValidUrl

  • Checks if the given URL can be parsed by the URL class. Note that this is pretty strict: many values which can be correctly handled by parseUrl will fail this. (For example, the protocol must be included for this to pass.)

    Parameters

    • input: string | URL | Readonly<Pick<{
          fullPath: string;
          hash: string;
          host: string;
          hostname: string;
          href: string;
          origin: string;
          password: string;
          pathname: string;
          paths: string[];
          port: string;
          protocol: string;
          search: string;
          searchParams: Required<Record<string, string[]>>;
          username: string;
      }, "href">>

    Returns boolean