fix: unable to clear preview image on can't get mimetype

This commit is contained in:
sxyazi 2023-11-12 11:31:22 +08:00
parent c49bf02ca4
commit a0da57a293
No known key found for this signature in database
2 changed files with 2 additions and 6 deletions

View file

@ -18,7 +18,7 @@ impl Manager {
} }
let Some(mime) = self.mimetype.get(url).cloned() else { let Some(mime) = self.mimetype.get(url).cloned() else {
return false; return self.active_mut().preview.reset(|_| true);
}; };
if sequent { if sequent {

View file

@ -49,17 +49,13 @@ impl MimeKind {
} }
pub fn valid(s: &str) -> bool { pub fn valid(s: &str) -> bool {
if s == "inode/x-empty" {
return true;
}
let parts = s.split('/').collect::<Vec<_>>(); let parts = s.split('/').collect::<Vec<_>>();
if parts.len() != 2 { if parts.len() != 2 {
return false; return false;
} }
#[rustfmt::skip] #[rustfmt::skip]
let b = matches!(parts[0], "application" | "audio" | "example" | "font" | "image" | "message" | "model" | "multipart" | "text" | "video"); let b = matches!(parts[0], "application" | "audio" | "example" | "font" | "image" | "inode" | "message" | "model" | "multipart" | "text" | "video");
b && !parts[1].is_empty() b && !parts[1].is_empty()
} }