Url.to_file_path() doesn't produce UNC path on Windows
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
Url.to_file_path() doesn't produce a UNC path on Windows, even when the Url was initialized with a UNC path via Url.from_file_path(). Thus this program:
extern crate url;
use std::path::Path;
use url::Url;
fn main() {
let unc_path = Path::new(r"\\?\C:\Windows\System");
let url = Url::from_file_path(unc_path).expect("url");
let abs_path_buf = url.to_file_path().expect("path");
let abs_path = abs_path_buf.as_path();
assert_eq!(unc_path, abs_path);
}
Fails with:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `"\\\\?\\C:\\Windows\\System"`,
right: `"C:\\Windows\\System"`', src\main.rs:11:2
It seems like Url.to_file_path() should produce a UNC path, at least when the Url was initialized with one; and perhaps in all cases, for compatibility with std::fs::canonicalize(), which always produces UNC paths on Windows (although this is controversial, per https://github.com/rust-lang/rust/issues/42869).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Windows example and reading the behavior of Url::from_file_path() and Url::to_file_path(). Trace how the UNC prefix is handled during the round trip. Done means a UNC path initialized with Url::from_file_path() is returned unchanged by to_file_path(), with the example assertion passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100