MIMEType
interfacestring
string
Map<string, string>
string
parseMIMEType(input)
Implements parse a MIME type.
Parses a MIME type, returning its type, subtype, and any associated parameters. If the parser can't parse an input it returns the string literal 'failure'
.
import { parseMIMEType } from 'undici' parseMIMEType('text/html; charset=gbk') // { // type: 'text', // subtype: 'html', // parameters: Map(1) { 'charset' => 'gbk' }, // essence: 'text/html' // }
Arguments:
string
Returns: MIMEType|'failure'
serializeAMimeType(input)
Implements serialize a MIME type.
Serializes a MIMEType object.
import { serializeAMimeType } from 'undici' serializeAMimeType({ type: 'text', subtype: 'html', parameters: new Map([['charset', 'gbk']]), essence: 'text/html' }) // text/html;charset=gbk
Arguments:
MIMEType
Returns: string