Commit b18549a

Eric Bower  ·  2026-07-16 19:59:19 -0400 EDT
parent 4af7648
fix: mime type case statement fallthrough
2 files changed,  +8, -12
+4, -8
 1@@ -18,11 +18,9 @@ func GetMimeType(fpath string) string {
 2 		return "image/x-icon"
 3 	case ".pdf":
 4 		return "application/pdf"
 5-	case ".htm":
 6-	case ".html":
 7+	case ".htm", ".html":
 8 		return "text/html"
 9-	case ".jpeg":
10-	case ".jpg":
11+	case ".jpeg", ".jpg":
12 		return "image/jpeg"
13 	case ".png":
14 		return "image/png"
15@@ -40,8 +38,7 @@ func GetMimeType(fpath string) string {
16 		return "font/ttf"
17 	case ".md":
18 		return "text/markdown; charset=UTF-8"
19-	case ".map":
20-	case ".json":
21+	case ".map", ".json":
22 		return "application/json"
23 	case ".rss":
24 		return "application/rss+xml"
25@@ -75,8 +72,7 @@ func GetMimeType(fpath string) string {
26 		return "text/x-opml"
27 	case ".eot":
28 		return "application/vnd.ms-fontobject"
29-	case ".yaml":
30-	case ".yml":
31+	case ".yaml", ".yml":
32 		return "text/x-yaml"
33 	case ".zip":
34 		return "application/zip"
+4, -4
 1@@ -102,11 +102,12 @@ func (s *StorageFS) DeleteBucket(bucket Bucket) error {
 2 }
 3 
 4 func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderAtCloser, *ObjectInfo, error) {
 5+	contentType := mime.GetMimeType(fpath)
 6 	objInfo := &ObjectInfo{
 7 		Size:         0,
 8 		LastModified: time.Time{},
 9 		ETag:         "",
10-		ContentType:  "",
11+		ContentType:  contentType,
12 	}
13 
14 	dat, err := os.Open(filepath.Join(bucket.Path, fpath))
15@@ -119,6 +120,8 @@ func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderA
16 		_ = dat.Close()
17 		return nil, objInfo, err
18 	}
19+	objInfo.Size = info.Size()
20+	objInfo.LastModified = info.ModTime()
21 
22 	etag := ""
23 	// only generate etag if file is less than 10MB
24@@ -141,9 +144,6 @@ func (s *StorageFS) GetObject(bucket Bucket, fpath string) (utils.ReadAndReaderA
25 	}
26 
27 	objInfo.ETag = etag
28-	objInfo.Size = info.Size()
29-	objInfo.LastModified = info.ModTime()
30-	objInfo.ContentType = mime.GetMimeType(fpath)
31 	return dat, objInfo, nil
32 }
33