sttp icon indicating copy to clipboard operation
sttp copied to clipboard

uri"".scheme().port() renders wrong uri

Open kamilkloch opened this issue 3 years ago • 3 comments

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

kamilkloch avatar May 09 '22 16:05 kamilkloch

Hm :) Is 192.168.1.1 a valid URI? (according to the spec?)

But why it ends up as a port is puzzling :)

adamw avatar May 09 '22 16:05 adamw

Fair point. https://datatracker.ietf.org/doc/html/rfc3986#section-1.1.1 Shall I close the issue?

kamilkloch avatar May 09 '22 16:05 kamilkloch

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.

adamw avatar May 09 '22 17:05 adamw

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 .

Pask423 avatar Oct 24 '22 17:10 Pask423