Fixed a bug where search terms with spaces didn't work

This commit is contained in:
Antoine Gersant 2017-11-03 20:09:42 -07:00
parent 962ba5efc7
commit d06263cff7

View file

@ -439,6 +439,10 @@ fn search(request: &mut Request, db: &DB) -> IronResult<Response> {
.url .url
.path() .path()
.join(&::std::path::MAIN_SEPARATOR.to_string()); .join(&::std::path::MAIN_SEPARATOR.to_string());
let query = match percent_decode(query.as_bytes()).decode_utf8() {
Ok(s) => s,
Err(_) => return Err(Error::from(ErrorKind::EncodingError).into()),
};
let search_result = index::search(db, &query)?; let search_result = index::search(db, &query)?;
let result_json = serde_json::to_string(&search_result); let result_json = serde_json::to_string(&search_result);
let result_json = match result_json { let result_json = match result_json {