mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:41:25 +00:00
refactor(media): centralize voice compatibility policy
This commit is contained in:
@@ -52,7 +52,7 @@ const AUDIO_FILE_EXTENSIONS = new Set([
|
||||
".wav",
|
||||
]);
|
||||
|
||||
function normalizeHeaderMime(mime?: string | null): string | undefined {
|
||||
export function normalizeMimeType(mime?: string | null): string | undefined {
|
||||
if (!mime) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ async function detectMimeImpl(opts: {
|
||||
const ext = getFileExtension(opts.filePath);
|
||||
const extMime = ext ? MIME_BY_EXT[ext] : undefined;
|
||||
|
||||
const headerMime = normalizeHeaderMime(opts.headerMime);
|
||||
const headerMime = normalizeMimeType(opts.headerMime);
|
||||
const sniffed = await sniffMime(opts.buffer);
|
||||
|
||||
// Prefer sniffed types, but don't let generic container types override a more
|
||||
@@ -145,10 +145,11 @@ async function detectMimeImpl(opts: {
|
||||
}
|
||||
|
||||
export function extensionForMime(mime?: string | null): string | undefined {
|
||||
if (!mime) {
|
||||
const normalized = normalizeMimeType(mime);
|
||||
if (!normalized) {
|
||||
return undefined;
|
||||
}
|
||||
return EXT_BY_MIME[mime.toLowerCase()];
|
||||
return EXT_BY_MIME[normalized];
|
||||
}
|
||||
|
||||
export function isGifMedia(opts: {
|
||||
|
||||
Reference in New Issue
Block a user