Serializes the media type and the optional parameters as a media type conforming to RFC 2045 and RFC 2616.
The type and parameter names are written in lower-case.
When any of the arguments results in a standard violation then the return value will be an empty string ("").
""
The media type to serialize.
Optional
Optional parameters to serialize.
The serialized media type.
import { formatMediaType } from "@std/media-types/format-media-type";import { assertEquals } from "@std/assert";assertEquals(formatMediaType("text/plain"), "text/plain"); Copy
import { formatMediaType } from "@std/media-types/format-media-type";import { assertEquals } from "@std/assert";assertEquals(formatMediaType("text/plain"), "text/plain");
import { formatMediaType } from "@std/media-types/format-media-type";import { assertEquals } from "@std/assert";assertEquals(formatMediaType("text/plain", { charset: "UTF-8" }), "text/plain; charset=UTF-8"); Copy
import { formatMediaType } from "@std/media-types/format-media-type";import { assertEquals } from "@std/assert";assertEquals(formatMediaType("text/plain", { charset: "UTF-8" }), "text/plain; charset=UTF-8");
Serializes the media type and the optional parameters as a media type conforming to RFC 2045 and RFC 2616.
The type and parameter names are written in lower-case.
When any of the arguments results in a standard violation then the return value will be an empty string (
"").