Skip to content

windows: to_file_path() panics for certain URLs created by from_file_path() #505

Open
@piscisaureus

Description

@piscisaureus
use std::path::PathBuf;
use url::Url;

fn main() {
    let p = PathBuf::from("c:///");
    let u = Url::from_file_path(p).unwrap();
    println!("url: {:?}", u);
    let r = u.to_file_path();  // <-- Panic happens here
    println!("result: {:?}", r);
}

output:

url: "file:///C:"
thread 'main' panicked at 'to_file_path() failed to produce an absolute Path', C:\Users\BertBelder\.cargo\registry\src\github.com-1ecc6299db9ec823\url-1.7.2\src\lib.rs:2415:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: process didn't exit successfully: `target\debug\urlt.exe` (exit code: 101)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions