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

x/xserver/src/deps.ts>media.extension

X-Server a Deno server module with middleware
Go to Latest
function media.extension
import { media } from "https://deno.land/x/xserver@2.0.0/src/deps.ts";
const { extension } = media;

For a given media type, return the most relevant extension, or undefined if no extension can be found.

Extensions are returned without a leading ..

Examples

Example 1

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

extension("text/plain"); // `txt`
extension("application/json"); // `json`
extension("text/html; charset=UTF-8"); // `html`
extension("application/foo"); // undefined

Parameters

type: string

Returns

string | undefined