From 9abd091796ca8ab4bd94c7fb70d83d38038ac075 Mon Sep 17 00:00:00 2001 From: Friday Date: Tue, 30 Jun 2026 08:03:45 +0000 Subject: [PATCH] fix: normalize .wav MIME type to audio/wav System MIME databases vary: some return audio/x-wav for .wav, which causes TestDetectMediaType to fail on certain CI images. Force the canonical audio/wav type for .wav files so the test is deterministic across environments. --- internal/ui/fileutil/processor.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/ui/fileutil/processor.go b/internal/ui/fileutil/processor.go index f8735176..8adc7c08 100644 --- a/internal/ui/fileutil/processor.go +++ b/internal/ui/fileutil/processor.go @@ -243,6 +243,15 @@ func wrapFileContent(absPath string, content []byte) string { func detectMediaType(path string, content []byte) string { // Extension-based detection is more reliable for well-known types. ext := strings.ToLower(filepath.Ext(path)) + + // Some system MIME databases return legacy or inconsistent types + // (e.g. audio/x-wav instead of audio/wav). Force canonical types + // for extensions we explicitly support. + switch ext { + case ".wav": + return "audio/wav" + } + if mt := mime.TypeByExtension(ext); mt != "" { // mime.TypeByExtension returns types like "image/png; charset=utf-8" // — strip parameters.