|
@@ -197,14 +197,6 @@ fn unescape(input: &str) -> String {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-fn set_path(url: &mut Url, path: Vec<String>) {
|
|
|
|
|
- match url.scheme_data {
|
|
|
|
|
- RelativeSchemeData(ref mut scheme_data) => scheme_data.path = path,
|
|
|
|
|
- _ => fail!()
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
#[test]
|
|
#[test]
|
|
|
fn file_paths() {
|
|
fn file_paths() {
|
|
|
assert_eq!(Url::from_file_path(&path::posix::Path::new("relative")), Err(()));
|
|
assert_eq!(Url::from_file_path(&path::posix::Path::new("relative")), Err(()));
|
|
@@ -219,14 +211,14 @@ fn file_paths() {
|
|
|
assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string()]));
|
|
assert_eq!(url.path(), Some(&["foo".to_string(), "bar".to_string()]));
|
|
|
assert!(url.to_file_path() == Ok(path::posix::Path::new("/foo/bar")));
|
|
assert!(url.to_file_path() == Ok(path::posix::Path::new("/foo/bar")));
|
|
|
|
|
|
|
|
- set_path(&mut url, vec!["foo".to_string(), "ba\0r".to_string()]);
|
|
|
|
|
|
|
+ *url.path_mut().unwrap().get_mut(1) = "ba\0r".to_string();
|
|
|
assert!(url.to_file_path::<path::posix::Path>() == Err(()));
|
|
assert!(url.to_file_path::<path::posix::Path>() == Err(()));
|
|
|
|
|
|
|
|
- set_path(&mut url, vec!["foo".to_string(), "ba%00r".to_string()]);
|
|
|
|
|
|
|
+ *url.path_mut().unwrap().get_mut(1) = "ba%00r".to_string();
|
|
|
assert!(url.to_file_path::<path::posix::Path>() == Err(()));
|
|
assert!(url.to_file_path::<path::posix::Path>() == Err(()));
|
|
|
|
|
|
|
|
// Invalid UTF-8
|
|
// Invalid UTF-8
|
|
|
- set_path(&mut url, vec!["foo".to_string(), "ba%80r".to_string()]);
|
|
|
|
|
|
|
+ *url.path_mut().unwrap().get_mut(1) = "ba%80r".to_string();
|
|
|
assert!(url.to_file_path() == Ok(path::posix::Path::new(
|
|
assert!(url.to_file_path() == Ok(path::posix::Path::new(
|
|
|
/* note: byte string, invalid UTF-8 */ b"/foo/ba\x80r")));
|
|
/* note: byte string, invalid UTF-8 */ b"/foo/ba\x80r")));
|
|
|
|
|
|
|
@@ -236,14 +228,14 @@ fn file_paths() {
|
|
|
assert!(url.to_file_path::<path::windows::Path>()
|
|
assert!(url.to_file_path::<path::windows::Path>()
|
|
|
== Ok(path::windows::Path::new(r"C:\foo\bar")));
|
|
== Ok(path::windows::Path::new(r"C:\foo\bar")));
|
|
|
|
|
|
|
|
- set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba\0r".to_string()]);
|
|
|
|
|
|
|
+ *url.path_mut().unwrap().get_mut(2) = "ba\0r".to_string();
|
|
|
assert!(url.to_file_path::<path::windows::Path>() == Err(()));
|
|
assert!(url.to_file_path::<path::windows::Path>() == Err(()));
|
|
|
|
|
|
|
|
- set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba%00r".to_string()]);
|
|
|
|
|
|
|
+ *url.path_mut().unwrap().get_mut(2) = "ba%00r".to_string();
|
|
|
assert!(url.to_file_path::<path::windows::Path>() == Err(()));
|
|
assert!(url.to_file_path::<path::windows::Path>() == Err(()));
|
|
|
|
|
|
|
|
// Invalid UTF-8
|
|
// Invalid UTF-8
|
|
|
- set_path(&mut url, vec!["C:".to_string(), "foo".to_string(), "ba%80r".to_string()]);
|
|
|
|
|
|
|
+ *url.path_mut().unwrap().get_mut(2) = "ba%80r".to_string();
|
|
|
assert!(url.to_file_path::<path::windows::Path>() == Err(()));
|
|
assert!(url.to_file_path::<path::windows::Path>() == Err(()));
|
|
|
}
|
|
}
|
|
|
|
|
|