can't parse uri without scheme but having path
swanandx opened this issue · comments
Swanand Mulay commented
I expect example.org/path
to be valid Uri, but parse()
returns an InvalidFormat
error
use http::Uri;
fn main() {
let uri: Uri = "example.org/path".parse().unwrap();
dbg!(uri.authority());
}
// ^this will result in:
// thread 'main' panicked at src/main.rs:4:47:
// called `Result::unwrap()` on an `Err` value: InvalidUri(InvalidFormat)
note: http://example.org/path
is parsed correctly!
Sean McArthur commented
Exactly. That is not a valid Uri. There are 4 main options, defined in the HTTP specs.
Swanand Mulay commented
Oh, using this for connecting to servers was quite common like broker.mqttdashboard.com/mqtt
, so I thought it's valid 😅
Thanks for your response, can you please point me to the specific part in standards 😁