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

x/fastro/http/server/deps.ts>typeByExtension

Full Stack Framework for Deno, TypeScript, Preact JS and Tailwind CSS
Go to Latest
function typeByExtension
Re-export
import { typeByExtension } from "https://deno.land/x/fastro@v0.88.1/http/server/deps.ts";

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.

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