sttp
sttp copied to clipboard
uri"".scheme().port() renders wrong uri
val uri = uri"192.168.1.1".scheme("http").port(8888)
println(uri)
http://:8888192.168.1.1
In contrast,
val uri = uri"http://192.168.1.1".port(8888)
println(uri)
http://192.168.1.1:8888
Hm :) Is 192.168.1.1 a valid URI? (according to the spec?)
But why it ends up as a port is puzzling :)
Fair point. https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.1 Shall I close the issue?
Not necessarily, uri in fact supports both relative & absolute URIs (see https://datatracker.ietf.org/doc/html/rfc3986#section-4.1), so I would expect if anything for the above to be parsed as a path component (but not port). So there might be sth wrong with relative URI handling.
As for now, parsing relative URIs works fine. 192.168.1.1 is parsed as a relative URI and ends up as a path segment. Adding schema by scheme("http") is effectively changing relative URI to absolute URI - what is not currently supported in sttp. Yet after the change remains 192.168.1.1 a path segment not part of the port in the URI object .