From 36d4889983dfb0c5aec59b649508a6fd0d7f127f Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 2 May 2023 13:07:04 +0200 Subject: [PATCH] resolve crash when there a directory --- src/routes/blog.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 5ecd63a..953ea39 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -99,7 +99,10 @@ fn get_posts(location: &str) -> Vec { let entries = match std::fs::read_dir(location) { Ok(res) => res .flatten() - .filter(|f| f.path().extension().unwrap() == "md") + .filter(|f| match f.path().extension() { + Some(ext) => ext == "md", + None => false, + }) .collect::>(), Err(_) => vec![], };