fun isUrl(candidateUrl: String): Boolean(source)

Check whether a given string is a valid URL.

Please note that this function is not all mighty and it only tries to convert the given string to URL and then to URI. This means that it fails to recognize invalid urls such as, or https://. For more complex validation, one should probably use Apache URL Validator.

For the sample cases when this simple method fails please see isUrlFalsePositives test in the file OtherExtensionsTest.kt.


true iff candidateUrl is a valid URL.



A candidate URL to be checked.

See documentation for isUrl.