Bladeren bron

fixing handling of canonicalized path on windows

fixed the handling for paths in the form of "\\?\C:\..."
Yoav Alon 10 jaren geleden
bovenliggende
commit
ec2993de44
2 gewijzigde bestanden met toevoegingen van 5 en 0 verwijderingen
  1. 1 0
      src/lib.rs
  2. 4 0
      tests/tests.rs

+ 1 - 0
src/lib.rs

@@ -1084,6 +1084,7 @@ fn path_to_file_url_path_windows(path: &Path) -> Result<Vec<String>, ()> {
     let disk = match components.next() {
         Some(Component::Prefix(ref p)) => match p.kind() {
             Prefix::Disk(byte) => byte,
+            Prefix::VerbatimDisk(byte) => byte,
             _ => return Err(()),
         },
 

+ 4 - 0
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());
     }
 }