mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 03:23:02 +00:00
refactor(MIME): add getMimeTypeFromExt function
This commit is contained in:
@@ -25,7 +25,7 @@ export function isDataLooksLikeAudio(buffer: Uint8Array): boolean {
|
||||
return ok;
|
||||
}
|
||||
|
||||
export const AudioMimeType: { [key: string]: string } = {
|
||||
const AudioMimeType: Record<string, string> = {
|
||||
mp3: 'audio/mpeg',
|
||||
flac: 'audio/flac',
|
||||
m4a: 'audio/mp4',
|
||||
@@ -34,3 +34,7 @@ export const AudioMimeType: { [key: string]: string } = {
|
||||
wav: 'audio/x-wav',
|
||||
dff: 'audio/x-dff',
|
||||
};
|
||||
|
||||
export function getMimeTypeFromExt(ext: string) {
|
||||
return AudioMimeType[ext] || 'application/octet-stream';
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { DecipherFactory, DecipherInstance, Status } from '~/decrypt-worker/Deci
|
||||
import { UnsupportedSourceFile } from '~/decrypt-worker/util/DecryptError.ts';
|
||||
import { ready as umCryptoReady } from '@unlock-music/crypto';
|
||||
import { go } from '~/util/go.ts';
|
||||
import { AudioMimeType, detectAudioExtension } from '~/decrypt-worker/util/audioType.ts';
|
||||
import { getMimeTypeFromExt, detectAudioExtension } from '~/decrypt-worker/util/audioType.ts';
|
||||
|
||||
class DecryptCommandHandler {
|
||||
private readonly label: string;
|
||||
@@ -75,7 +75,7 @@ class DecryptCommandHandler {
|
||||
audioExt = 'm4a';
|
||||
}
|
||||
|
||||
return { decrypted: URL.createObjectURL(toBlob(result.data, AudioMimeType[audioExt])), ext: audioExt };
|
||||
return { decrypted: URL.createObjectURL(toBlob(result.data, getMimeTypeFromExt(audioExt))), ext: audioExt };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user