Skip to main content
Go to Latest
function typeByExtension
import { typeByExtension } from "";

Returns 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.


Example 1

import { typeByExtension } from "";

typeByExtension("js"); // "application/json"
typeByExtension(".HTML"); // "text/html"
typeByExtension("foo"); // undefined
typeByExtension("file.json"); // undefined


extension: string


string | undefined