x/oak/deps.ts

A middleware framework for handling HTTP with Deno 🐿️ 🦕
Very Popular
Go to Latest
function typeByExtension
import { typeByExtension } from "https://dotland-vbqsvsrpfncg.deno-staging.dev/x/oak@v11.1.0/deps.ts?s=typeByExtension";

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

import { typeByExtension } from "https://deno.land/std@$STD_VERSION/media_types/mod.ts";

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

Parameters

extension: string[src]

Returns

string | undefined[src]