url-vir - v2.1.6
    Preparing search index...

    Function toValidUrl

    • Attempt to convert the input input a valid URL string via the URL class. If the conversion fails, undefined is returned. 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: Record<string, string[]>;
                        username: string;
                    },
                    "href",
                >,
            >

      Returns undefined | string

      Url string if input can be parsed. Otherwise, undefined.