1
0

Fix CSV errors for rendering (#514)

هذا الالتزام موجود في:
Thomas Miceli
2025-09-29 19:02:33 +02:00
ملتزم من قبل GitHub
الأصل 92c5569538
التزام 5ef5518795
7 ملفات معدلة مع 21 إضافات و15 حذوفات

عرض الملف

@@ -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}
}