-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Description
- Note that this crate implements the URL Standard not RFC 1738 or RFC 3986
Describe the bug
The use of from_file_path() will produce a different Url when the path has .. in the path segments compared to Url::parse. What this means in essence is that the only way to ensure that a file path is "canonicalized" is to
let u = Url::from_file_path("/home/tyler/../../dev/null");
let u = Url::parse(fu.as_str())?Reproduction
use url::Url;
fn main() {
let fu = Url::parse("file:///home/tyler/../../dev/null").expect("oops");
let u = Url::from_file_path("/home/tyler/../../dev/null")
.expect("Failed to parse file path");
assert_eq!(fu, u, "The Url objects themselves are different");
} Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.81s
Running `target/debug/playground`
thread 'main' (13) panicked at src/main.rs:7:5:
assertion `left == right` failed: The Url objects themselves are different
left: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/dev/null", query: None, fragment: None }
right: Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/tyler/../../dev/null", query: None, fragment: None }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Metadata
Metadata
Assignees
Labels
No labels