forked from neri/datatrash
use html view even if content matches text/html
This commit is contained in:
parent
7f26e7c456
commit
d9c92a2827
|
@ -434,7 +434,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "datatrash"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
dependencies = [
|
||||
"actix-files",
|
||||
"actix-multipart",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "datatrash"
|
||||
version = "1.1.0"
|
||||
version = "1.1.1"
|
||||
authors = ["neri"]
|
||||
edition = "2021"
|
||||
|
||||
|
|
|
@ -91,6 +91,9 @@ async fn get_view_type(
|
|||
if delete_on_download || req.query_string().contains("dl") {
|
||||
return ViewType::Download;
|
||||
}
|
||||
if req.query_string().contains("raw") {
|
||||
return ViewType::Raw;
|
||||
}
|
||||
let is_text =
|
||||
FileKind::from_str(file_kind) == Ok(FileKind::Text) || file_mime.type_() == mime::TEXT;
|
||||
if !is_text {
|
||||
|
@ -101,18 +104,15 @@ async fn get_view_type(
|
|||
}
|
||||
if let Ok(accept) = Accept::parse(req) {
|
||||
for accept_mime in accept.ranked() {
|
||||
if mime_matches(&accept_mime, file_mime) {
|
||||
return ViewType::Raw;
|
||||
}
|
||||
if accept_mime == TEXT_HTML {
|
||||
return ViewType::Html;
|
||||
}
|
||||
if mime_matches(&accept_mime, file_mime) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return ViewType::Raw;
|
||||
}
|
||||
|
||||
ViewType::Html
|
||||
ViewType::Raw
|
||||
}
|
||||
|
||||
fn mime_matches(accept: &Mime, content: &Mime) -> bool {
|
||||
|
|
Loading…
Reference in New Issue