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

host returns Host::Domain with custom protocols even though it is an IP address #767

Open
tbu- opened this issue May 4, 2022 · 2 comments

Comments

@tbu-
Copy link

tbu- commented May 4, 2022

This should at least be documented as a pitfall.

use url::Url;
fn main() {
    println!("{:?}", Url::parse("http://127.0.0.1").unwrap().host());
    println!("{:?}", Url::parse("custom://127.0.0.1").unwrap().host());
}
$ cargo run
[…]
Some(Ipv4(127.0.0.1))
Some(Domain("127.0.0.1"))
@lufte
Copy link

lufte commented Aug 29, 2022

This is probably a duplicate of #606 in which it is explained that this is part of the URL standard.

I also created #763 to request a compile-time setting for including more schemes to this standard list of "special" schemes that have this behavior. In the meantime I forked the library and hardcoded the schemes I needed myself, maybe this works for you too: master...lufte:rust-url:gemini

@tmccombs
Copy link
Contributor

tmccombs commented Sep 2, 2022

Given how often something like this comes up. It might be worth at least adding something to the crate documentation to warn that the behavior is different for "special" schemes, and why that is.

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

3 participants