diff options
Diffstat (limited to 'src/file_upload.rs')
-rw-r--r-- | src/file_upload.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/file_upload.rs b/src/file_upload.rs index 534083c..88f8a7c 100644 --- a/src/file_upload.rs +++ b/src/file_upload.rs @@ -101,10 +101,11 @@ fn handle_multipart( /// invalid. /// This method returns future. pub fn upload_file(req: &HttpRequest<crate::MiniserveConfig>) -> FutureResponse<HttpResponse> { - let return_path: String = req.headers()[header::REFERER] - .to_str() - .unwrap_or("/") - .to_owned(); + let return_path = if let Some(header) = req.headers().get(header::REFERER) { + header.to_str().unwrap_or("/").to_owned() + } else { + "/".to_string() + }; let app_root_dir = if let Ok(dir) = req.state().path.canonicalize() { dir } else { |