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

IP is not recognized in RTSP url #606

Closed
0xd34d10cc opened this issue Jun 16, 2020 · 4 comments
Closed

IP is not recognized in RTSP url #606

0xd34d10cc opened this issue Jun 16, 2020 · 4 comments

Comments

@0xd34d10cc
Copy link

0xd34d10cc commented Jun 16, 2020

I would expect the following assert to pass:

    assert_eq!(
        Url::parse("http://1.35.33.49").unwrap().host(),
        Url::parse("rtsp://1.35.33.49").unwrap().host()
    )

but it does not:

assertion failed: `(left == right)`
  left: `Some(Ipv4(1.35.33.49))`,
 right: `Some(Domain("1.35.33.49"))`', src/main.rs:4:5
@djc
Copy link
Contributor

djc commented Aug 24, 2020

The URL Standard has special handling for several URL schemes (one of which is http) that includes parsing the host address to check for IPv4 addresses, but this is not used for unrecognized schemes. Why is the equivalence important to your use case?

@0xd34d10cc
Copy link
Author

It's not really important . It's just inconvenient. I have to write code like this:

match host {
    Host::Domain(name) => {
        if let Ok(ip) = name.parse::<IpAddr>() {
            ip
        } else {
            resolve(name)
        }
    }
    Host::Ipv4(ip) => IpAddr::V4(ip),
    Host::Ipv6(ip) => IpAddr::V6(ip),
}

to gen ip address from url.

I didn't know that this was the intended behavior, it looked like a bug to me. Since that's how the URL Standard requires the parser to work the issue could be closed.

@tmccombs
Copy link
Contributor

The URL Standard has special handling for several URL schemes (one of which is http) that includes parsing the host address to check for IPv4 addresses, but this is not used for unrecognized schemes. Why is the equivalence important to your use case?

What is the motivation of that? I can't think of any scheme, except maybe "file", where the host can't be an ip address.

@djc
Copy link
Contributor

djc commented Aug 24, 2020

See here: #577 (comment).

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