Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't parse uri without scheme but having path #666

Closed
swanandx opened this issue Jan 27, 2024 · 4 comments
Closed

can't parse uri without scheme but having path #666

swanandx opened this issue Jan 27, 2024 · 4 comments

Comments

@swanandx
Copy link

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!

@robjtede
Copy link

This is working as intended. See #523 for details.

@seanmonstar
Copy link
Member

Exactly. That is not a valid Uri. There are 4 main options, defined in the HTTP specs.

@seanmonstar seanmonstar closed this as not planned Won't fix, can't repro, duplicate, stale Jan 27, 2024
@swanandx
Copy link
Author

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 😁

@sfackler
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants