servo / servo/rust-url

Support for converting between unix-style `Path` and `Url` on Windows

Open
#730 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
406
PR merge metrics
No merged PRs in 30d

Description

Often in tests I'll use only unix style paths (ex. /data/test.txt) because it works with Path on both Windows and Unix.

The problem I have though, is the Url::from_file_path(path) and url.to_file_path() both error on Windows for these kind of paths and specifiers in this crate even though they can be represented just fine as a std::path::Path. For example:

let path = PathBuf::from("/testing");
// Unix: Ok(_)
// Windows: Err(())
println!("{:?}", Url::from_file_path(&path));

let url = Url::parse("file:///testing").unwrap();
// Unix: Ok("/testing")
// Windows: Err(())
println!("{:?}", url.to_file_path());

Is there a reason these aren't supported on Windows? Would you accept a PR that adds support for this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing Url::from_file_path and Url::to_file_path on Windows, comparing their handling of unix-style paths with std::path::Path. Confirm the intended behavior for the examples in this issue and add coverage for both conversions; done means those examples no longer return Err(()) on Windows without breaking existing path handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.