isUrl

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 https://sm.ai, 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.

Return

true iff candidateUrl is a valid URL.

Parameters

candidateUrl

A candidate URL to be checked.


See documentation for isUrl.