Skip to content

Commit

Permalink
Don't crash when .mime file not exist in cache
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkassimo committed Dec 7, 2018
1 parent 6cc89b9 commit 8031e6b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/deno_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ impl DenoDir {
(source, map_content_type(&p, Some(&content_type)))
} else {
let source = fs::read_to_string(&p)?;
let content_type = fs::read_to_string(&mt)?;
(source, map_content_type(&p, Some(&content_type)))
let maybe_content_type_string = fs::read_to_string(&mt).ok();
// Option<String> -> Option<&str>
let maybe_content_type_str =
maybe_content_type_string.as_ref().map(String::as_str);
(source, map_content_type(&p, maybe_content_type_str))
};
Ok(src)
}
Expand Down

0 comments on commit 8031e6b

Please sign in to comment.