Skip to content

Commit

Permalink
Updated MIME types
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Oct 20, 2023
1 parent 6407548 commit 0e16697
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/mime_types/get_mime_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Deno.test(
getMIMEType(
defaultMIMETypes,
'html'
), 'text/html'
),
'text/html'
);
}
});
Expand All @@ -41,7 +42,7 @@ Deno.test(
assertEquals(
getMIMEType(
defaultMIMETypes,
'jsm'
'mjs'
),
'application/javascript'
);
Expand Down
13 changes: 12 additions & 1 deletion src/mime_types/get_mime_type.ts
Original file line number Diff line number Diff line change
@@ -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,
[
Expand Down

0 comments on commit 0e16697

Please sign in to comment.