diff --git a/src/mime_types/get_mime_type.test.ts b/src/mime_types/get_mime_type.test.ts index ae30cef..2a3b6c7 100644 --- a/src/mime_types/get_mime_type.test.ts +++ b/src/mime_types/get_mime_type.test.ts @@ -24,7 +24,8 @@ Deno.test( getMIMEType( defaultMIMETypes, 'html' - ), 'text/html' + ), + 'text/html' ); } }); @@ -41,7 +42,7 @@ Deno.test( assertEquals( getMIMEType( defaultMIMETypes, - 'jsm' + 'mjs' ), 'application/javascript' ); diff --git a/src/mime_types/get_mime_type.ts b/src/mime_types/get_mime_type.ts index cf11373..39999ba 100644 --- a/src/mime_types/get_mime_type.ts +++ b/src/mime_types/get_mime_type.ts @@ -1,6 +1,17 @@ import { MIMETypesObject } from "./mime_type_object.d.ts"; -export function getMIMEType(mIMETypesObject : MIMETypesObject, extension : string) : string { +/** + * This function returns the correct MIME type based on the file extension. If the extension does not exist on the MIME + * types object, the default MIME type gets returned. + * + * @param mIMETypesObject The MIME types object from where to get the MIME types + * @param extension The file extension to search for + * @returns The MIME type for the extension or the default MIME type + */ +export function getMIMEType( + mIMETypesObject : MIMETypesObject, + extension : string +) : string { const MIMETypesMap = Object.entries(mIMETypesObject.types).reduce(( map, [