Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lume/deps/media_types.ts>typeByExtension

🔥 Static site generator for Deno 🦕
Very Popular
Go to Latest
function typeByExtension
Re-export
Deprecated
Deprecated

(will be removed in 0.209.0) Use contentType instead.

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.

import { typeByExtension } from "https://deno.land/x/lume@v1.19.1/deps/media_types.ts";

Examples

Example 1

import { typeByExtension } from "https://deno.land/std@0.224.0/media_types/type_by_extension.ts";

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

Parameters

extension: string

Returns

string | undefined