contentTypefunctionfunction contentType(pathOrExtension: string): stringWhat a Content-Type header says for a path or an extension: its media type, with ; charset=UTF-8 for text; application/octet-stream where it is not known.
Media types by file extension (commons 0001-formats FR-018): what a server says a file is, with charset=UTF-8 on text, so a page, a stylesheet, a feed or a book is served as what it is. The table holds the types the harnesses serve and publish (web, documents, images, fonts, audio and video, archives, data); an extension it does not hold is application/octet-stream to contentType. Replaces @std/media-types in erga.
import { contentType, mediaType } from "./media-types.ts";
contentType("site/index.html"); // "text/html; charset=UTF-8"
mediaType(".epub"); // "application/epub+zip"contentTypefunctionfunction contentType(pathOrExtension: string): stringWhat a Content-Type header says for a path or an extension: its media type, with ; charset=UTF-8 for text; application/octet-stream where it is not known.
extensionOffunctionfunction extensionOf(pathOrExtension: string): stringThe extension of a path (site/index.html gives html), or an extension given on its own (.html or html), in lower case without its dot; "" where a path has none. A name that starts with a dot and has no other (.epub) is taken as an extension.
isTextualfunctionfunction isTextual(type: string): booleanWhether text of a media type is read as characters, and so served with a charset.
MEDIA_TYPESconstno test imports itconst MEDIA_TYPES: Readonly<Record<string, string>>The media type of each extension (lower case, without its dot).
mediaTypefunctionfunction mediaType(pathOrExtension: string): string | undefinedThe media type of a path or an extension, or undefined where the table does not hold it.