Fix media URL extension for m4a uploads

This commit is contained in:
richjohnrambo
2026-09-07 09:57:16 +08:00
parent 7a1647bf17
commit 6330c592cf
5 changed files with 59 additions and 17 deletions
+18
View File
@@ -219,3 +219,21 @@ func TestMatchCORSOrigin(t *testing.T) {
func containsSubstring(str, substr string) bool {
return strings.Contains(strings.ToLower(str), strings.ToLower(substr))
}
func TestExtensionByMimeType(t *testing.T) {
cases := map[string]string{
"audio/x-m4a": ".m4a",
"audio/x-m4a; charset=utf": ".m4a",
"audio/mp4": ".m4a",
"audio/aac": ".aac",
"audio/mpeg": ".mp3",
"image/jpeg": ".jpg",
"image/jfif": ".jfif",
"video/mp4": ".mp4",
}
for mimeType, want := range cases {
if got := ExtensionByMimeType(mimeType); got != want {
t.Fatalf("ExtensionByMimeType(%q)=%q, want %q", mimeType, got, want)
}
}
}