I'm trying to parse a Url that is user submitted, ...
# ktor
j
I'm trying to parse a Url that is user submitted, so it could be
<http://example.com>
or
<http://example.com|example.com>
, if I do
Url("<http://example.com|example.com>")
then it returns
<http://localhost>
which is quite confusing?
a
URLs are only valid with a protocol. You may want to use
java.net.URI
instead
j
fair enough 😊 I'm using this in a KMP project so can't do that, but I'll figure something out
seems weird to return
<http://localhost>
instead of throwing though
a
Ah. Not sure what would be a good fit in that case.
I do know that http4k's core module has a
Uri
class, but it may still be overkill.
I also don't know how compatible it would be with KMP 😅 . Hope you find something.
j
Thanks for the pointer! I'll take a look 😊
a
if you’re looking for a KMP URI library I’ve had this one bookmarked for a while, but I’ve not used it yet https://github.com/eygraber/uri-kmp
j
Thanks! i'll look into that too
r
Here is another one. I've used this on a KMP project without issues: https://github.com/chRyNaN/uri.