Fix commented issues.

This commit is contained in:
Danny Angelo Carminati Grein 2017-01-25 21:15:35 -05:00
parent f04e1bc4d7
commit b348be4e10
2 changed files with 2 additions and 4 deletions

View file

@ -82,7 +82,7 @@ pub fn get_api_handler(collection: Arc<Collection>) -> Mount {
}
fn path_from_request(request: &Request) -> Result<PathBuf> {
let path_string = request.url.path().join("/");
let path_string = request.url.path().join(&::std::path::MAIN_SEPARATOR.to_string());
let decoded_path = percent_decode(path_string.as_bytes()).decode_utf8()?;
Ok(PathBuf::from(decoded_path.deref()))
}

View file

@ -193,12 +193,10 @@ impl Config {
fn clean_path_string(path_string: &str) -> path::PathBuf {
let separator_regex = regex::Regex::new(r"\\|/").unwrap();
let trailing_regex = regex::Regex::new(r"(/)+$").unwrap();
let mut correct_separator = String::new();
correct_separator.push(path::MAIN_SEPARATOR);
let path_string = separator_regex.replace_all(path_string, correct_separator.as_str());
let path_string = trailing_regex.replace_all(&path_string, "");
path::PathBuf::from(path_string)
path::Path::new(&path_string).iter().collect()
}
#[test]