-
Notifications
You must be signed in to change notification settings - Fork 331
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
Missing "/" in path when url contains a scheme other than "https" #773
Comments
I bisected this change down to being introduced in #537 and released in v2.1.1, specifically the commit 9cd646. @o0Ignition0o and @nox - is this expected behavior, or is this a bug? |
Hey, sorry for the late reply. Good question, I m gonna check |
It looks like a but to me: Section 8 of scheme state mentions:
Let's see if I can write a test case. Edit: nvm, checking whether the path shall be |
This seems to be aligned with the comment @SimonSapin wrote in the path() getter:
Cannot be a base URLs only happen to special URLs |
Right, this is by design. I recommend closing this bug and perhaps adding documentation that if you want your custom scheme to have similar processing to a special scheme you need to implement that on top in a processor of sorts. |
Hi I have been investigating a similar inconsistency as well, this bug seems to be similar enough, let me know if you prefer a different issue to be opened. use url::{Host, Url};
fn url_parse(s: String) {
let result = Url::parse(&s);
println!("parsing: {}", s);
match result {
Ok(parsed) => {
println!("scheme: {}", parsed.scheme());
match parsed.host() {
Some(Host::Domain(s)) => println!("host: {}", s),
Some(Host::Ipv4(s)) => println!("host: {}", &s.to_string()),
Some(Host::Ipv6(s)) => println!("host: {}", &s.to_string()),
_ => println!("host: -"),
}
println!("path: {}", parsed.path());
}
Err(error) => {
println!("error: {}", error);
},
}
println!("");
}
fn main() {
// Statements here are executed when the compiled binary is called
url_parse("file://ciao//bye".to_string());
url_parse("http://ciao//bye".to_string());
// Print text to the console
url_parse("file:///ciao//bye".to_string());
url_parse("http:///ciao//bye".to_string());
} The output of this program is:
an identical program written in python is this one: from urllib.parse import urlparse
def url_parse(url):
parsed = urlparse(url)
print('parsing: ', url)
print('scheme: ', parsed.scheme)
print('host: ', parsed.netloc)
print('path: ', parsed.path)
print('')
url_parse("file://ciao//bye")
url_parse("http://ciao//bye")
url_parse("file:///ciao//bye")
url_parse("http:///ciao//bye") and it would output the following:
in particular python behaviour seems to be doing a better job in keeping trailing slashes in path, that in rust are silently dropped in some specific circumstances (file scheme vs http), and it has a more coherent behaviour regardless of the scheme. also the parsed outcome of "http:///ciao//bye" seems to be completely wrong in rust... |
It parses correctly as far as I can see |
Hi, I've been chasing down a bug in my application to this behavior which seems inconsistent with the docs. For example
The docs for
path
mention:It seems like URLs with a scheme other than HTTPS are correctly identified as can be a base, but the path does not start with / anyway. If I'm reading the docs correctly, all four of these tests should pass.
The text was updated successfully, but these errors were encountered: