Closed
Description
Hi, I've been chasing down a bug in my application to this behavior which seems inconsistent with the docs. For example
#[test]
fn url_parsing_library_is_sane() {
let url = url::Url::parse("https://example.com").unwrap();
assert_eq!(url.path(), "/"); // passes
}
#[test]
fn url_parsing_library_is_sane_2() {
let url = url::Url::parse("spartan://example.com").unwrap();
assert_eq!(url.path(), "/") // fails
}
#[test]
fn url_parsing_library_is_sane_3() {
let url = url::Url::parse("spartan://example.com").unwrap();
assert!(!url.cannot_be_a_base()); // passes
}
#[test]
fn url_parsing_library_is_sane_4() {
let url = url::Url::parse("asdfuiop://example.com").unwrap();
assert_eq!(url.path(), "/") // fails
}
The docs for path
mention:
For cannot-be-a-base URLs, this is an arbitrary string that doesn’t start with ‘/’. For other URLs, this starts with a ‘/’ slash and continues with slash-separated path segments.
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.
Metadata
Metadata
Assignees
Labels
No labels