function typeByExtension
typeByExtension(extension: string): string | undefinedReturns the media type associated with the file extension. Values are
normalized to lower case and matched irrespective of a leading ..
When extension has no associated type, the function returns undefined.
Examples
Example 1
Example 1
import { typeByExtension } from "@std/media-types/type_by_extension"; typeByExtension("js"); // "application/json" typeByExtension(".HTML"); // "text/html" typeByExtension("foo"); // undefined typeByExtension("file.json"); // undefined
Parameters
extension: stringReturn Type
string | undefined