Function typeByExtension
- type
By (extension): string | undefinedExtension Parameters
- extension: string
The file extension to get the media type for.
Returns string | undefined
The media type associated with the file extension, or
undefinedif no media type is found.Example: Usage
import { typeByExtension } from "@std/media-types/type-by-extension";
import { assertEquals } from "@std/assert";
assertEquals(typeByExtension("js"), "text/javascript");
assertEquals(typeByExtension(".HTML"), "text/html");
assertEquals(typeByExtension("foo"), undefined);
assertEquals(typeByExtension("file.json"), undefined);- extension: string
Returns the media type associated with the file extension, or
undefinedif no media type is found.Values are normalized to lower case and matched irrespective of a leading
..