fix: enhance MXF handling in mime-types utility
* Updated video mime type validation to include 'application/mxf'. * Adjusted asset type determination to recognize MXF as a video container.pull/24644/head
parent
9765538255
commit
5316bcf588
|
|
@ -189,7 +189,7 @@ describe('mimeTypes', () => {
|
||||||
|
|
||||||
it('should contain only video mime types', () => {
|
it('should contain only video mime types', () => {
|
||||||
const values = Object.values(mimeTypes.video).flat();
|
const values = Object.values(mimeTypes.video).flat();
|
||||||
expect(values).toEqual(values.filter((mimeType) => mimeType.startsWith('video/')));
|
expect(values).toEqual(values.filter((mimeType) => mimeType.startsWith('video/') || mimeType === 'application/mxf'));
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const [extension, v] of Object.entries(mimeTypes.video)) {
|
for (const [extension, v] of Object.entries(mimeTypes.video)) {
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,14 @@ export const mimeTypes = {
|
||||||
/** return an extension (including a leading `.`) for a mime-type */
|
/** return an extension (including a leading `.`) for a mime-type */
|
||||||
toExtension,
|
toExtension,
|
||||||
assetType: (filename: string) => {
|
assetType: (filename: string) => {
|
||||||
|
// Check file extension first to handle cases like MXF (application/mxf) that are video containers
|
||||||
|
if (isType(filename, video)) {
|
||||||
|
return AssetType.Video;
|
||||||
|
}
|
||||||
|
if (isType(filename, image)) {
|
||||||
|
return AssetType.Image;
|
||||||
|
}
|
||||||
|
// Fallback to mime type check for any edge cases
|
||||||
const contentType = lookup(filename);
|
const contentType = lookup(filename);
|
||||||
if (contentType.startsWith('image/')) {
|
if (contentType.startsWith('image/')) {
|
||||||
return AssetType.Image;
|
return AssetType.Image;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue