ktorio / ktor

Framework for quickly creating connected applications in Kotlin with minimal effort
https://ktor.io
Apache License 2.0
12.86k stars 1.04k forks source link

KTOR-360: add parseUrl function #4074

Closed anton-erofeev closed 3 months ago

anton-erofeev commented 3 months ago

Subsystem ktor-http

Motivation issue https://github.com/ktorio/ktor/issues/1903. Currently URL parsing returns a valid URL when an invalid URL is passed in (for "bogus" it returns "http://localhost/bogus"). Also there is no method that would return null instead of an exception if url parsing fails.

Solution added parseUrl function to the URLUtils.kt, it tries to parse the URL using the passed string and, if unsuccessful, returns null