Function extension
- extension(type): string | undefined
Parameters
- type: string
The media type to get the extension for.
Returns string | undefined
The extension for the given media type, or
undefinedif no extension is found.Example: Usage
import { extension } from "@std/media-types/extension";
import { assertEquals } from "@std/assert";
assertEquals(extension("text/plain"), "txt");
assertEquals(extension("application/json"), "json");
assertEquals(extension("text/html; charset=UTF-8"), "html");
assertEquals(extension("application/foo"), undefined);- type: string
Returns the most relevant extension for the given media type, or
undefinedif no extension can be found.Extensions are returned without a leading
..