Parcourir la source

Fix inverted logic in Url::to_file_path() for Windows paths.

Simon Sapin il y a 12 ans
Parent
commit
143d902a9c
2 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 1 1
      src/lib.rs
  2. 2 0
      src/tests.rs

+ 1 - 1
src/lib.rs

@@ -1465,7 +1465,7 @@ impl FromUrlPath for path::windows::Path {
             Some(path) => {
                 debug_assert!(path.is_absolute(),
                               "to_file_path() failed to produce an absolute Path")
-                debug_assert!(path::windows::prefix(&path) != Some(path::windows::DiskPrefix),
+                debug_assert!(path::windows::prefix(&path) == Some(path::windows::DiskPrefix),
                               "to_file_path() failed to produce a Path with a disk prefix")
                 Ok(path)
             }

+ 2 - 0
src/tests.rs

@@ -233,6 +233,8 @@ fn file_paths() {
     let mut url = Url::from_file_path(&path::windows::Path::new(r"C:\foo\bar")).unwrap();
     assert_eq!(url.host(), Some(&Domain("".to_string())));
     assert_eq!(url.path(), Some(&["C:".to_string(), "foo".to_string(), "bar".to_string()]));
+    assert!(url.to_file_path::<path::windows::Path>()
+            == Ok(path::windows::Path::new(r"C:\foo\bar")));
 
     set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba\0r".to_string()]);
     assert!(url.to_file_path::<path::windows::Path>() == Err(()));