From ec2993de44a2f4a04fd7d805362666580431ffc4 Mon Sep 17 00:00:00 2001 From: Yoav Alon Date: Wed, 13 Apr 2016 01:30:02 +0300 Subject: [PATCH] fixing handling of canonicalized path on windows fixed the handling for paths in the form of "\\?\C:\..." --- src/lib.rs | 1 + tests/tests.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 70e030fd..9caffad0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1084,6 +1084,7 @@ fn path_to_file_url_path_windows(path: &Path) -> Result, ()> { let disk = match components.next() { Some(Component::Prefix(ref p)) => match p.kind() { Prefix::Disk(byte) => byte, + Prefix::VerbatimDisk(byte) => byte, _ => return Err(()), }, diff --git a/tests/tests.rs b/tests/tests.rs index 45c403db..11d35cde 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -69,6 +69,10 @@ fn new_path_windows_fun() { // Invalid UTF-8 url.path_mut().unwrap()[2] = "ba%80r".to_string(); assert!(url.to_file_path().is_err()); + + // test windows canonicalized path + let path = PathBuf::from(r"\\?\C:\foo\bar"); + assert!(Url::from_file_path(path).is_ok()); } }