refactor(coverart): one image Content-Type table for /api and Subsonic (#8002)
api/media.go and subsonic/stream.go each had imageContentType, the same map in a different order, serving the same files. coverart.ImageContentType is now the one copy, with its test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -38,24 +38,6 @@ func TestAudioContentType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageContentType(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"/a/cover.jpg": "image/jpeg",
|
||||
"/a/cover.JPG": "image/jpeg",
|
||||
"/a/cover.jpeg": "image/jpeg",
|
||||
"/a/cover.png": "image/png",
|
||||
"/a/cover.webp": "image/webp",
|
||||
"/a/cover.gif": "image/gif",
|
||||
"/a/cover.bmp": "application/octet-stream",
|
||||
"/a/cover": "application/octet-stream",
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := imageContentType(in); got != want {
|
||||
t.Errorf("imageContentType(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindSidecarCover_PrefersCoverOverFolder(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.WriteFile(filepath.Join(dir, "cover.jpg"), []byte("c"), 0o644); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user