textConvert
    Preparing search index...

    Function isUrl

    • Validates if a string is a valid URL according to standard specifications.

      This function performs comprehensive validation including:

      • Protocol validation (http:// or https:// required)
      • Domain structure validation
      • Path, query parameter, and fragment handling
      • Special character checks
      • Length limits and format requirements

      Parameters

      • text: string

        The string to validate as a URL

      Returns boolean

      boolean indicating if the string is a valid URL

      isUrl('https://example.com')                      // true
      isUrl('http://example.com/path') // true
      isUrl('https://example.com/path?query=123') // true
      isUrl('https://sub.domain.example.co.uk/path') // true
      isUrl('ftp://example.com') // false (only http/https supported)
      isUrl('example.com') // false (protocol required)
      isUrl('not a url') // false