Function isValidUrl

  • Checks if the given string is a valid URL, including scheme URLs.


    const ret1 = isValidUrl('');
    const ret2 = isValidUrl('');
    const ret3 = isValidUrl('');
    const ret4 = isValidUrl('');
    const ret5 = isValidUrl('');
    console.log(ret1, ret2, ret3, ret4, ret5);


    true true true true true


    • url: string

      The URL to check.

    Returns boolean

    Returns true if the given string is a valid URL, else false.


    If you are specifically checking for HTTP/HTTPS URLs, it is recommended to use the isValidHttpUrl function instead. The isValidUrl function matches all scheme URLs, including FTP and other non-HTTP schemes.