Fix CSV errors for rendering (#514)

This commit is contained in:
Thomas Miceli
2025-09-29 19:02:33 +02:00
committed by GitHub
parent 92c5569538
commit 5ef5518795
7 changed files with 21 additions and 15 deletions

View File

@@ -9,6 +9,7 @@ import (
type MimeType struct {
ContentType string
extension string
}
func (mt MimeType) IsText() bool {
@@ -16,7 +17,8 @@ func (mt MimeType) IsText() bool {
}
func (mt MimeType) IsCSV() bool {
return strings.Contains(mt.ContentType, "text/csv")
return strings.Contains(mt.ContentType, "text/csv") &&
(strings.HasSuffix(mt.extension, ".csv"))
}
func (mt MimeType) IsImage() bool {
@@ -84,6 +86,6 @@ func (mt MimeType) RenderType() string {
return "Binary"
}
func DetectMimeType(data []byte) MimeType {
return MimeType{mimetype.Detect(data).String()}
func DetectMimeType(data []byte, extension string) MimeType {
return MimeType{mimetype.Detect(data).String(), extension}
}