address-header.d.ts

1.2 KB v1.0
import type { AddressObject, ParseAddressHeaderOptions } from './types.js';
/**
 * Parses the value of an address header (`From`, `To`, `Cc`, `Reply-To` and the like) into the
 * {@link AddressObject} `MailParser` and `simpleParser` produce for one: display names have their
 * encoded words decoded, an internationalized (punycode) domain is decoded to Unicode (unless
 * `decodePunycode` is false), and an
 * address part that hides an encoded word is dropped unless it decodes to a plain `local@domain`
 * (RFC 2047 keeps encoded words out of the address, so `[email protected]` naming
 * another address is not taken at its word).
 *
 * The value is the header value without the `Name:` prefix, as a string. Line folding may be left
 * in. Raw 8-bit bytes have to be decoded into the string first, eg. `buffer.toString('utf-8')`.
 * Several values (a header that occurs more than once) can be given as an array: each is parsed
 * on its own and the addresses are listed in order.
 *
 * @param value The header value, or several of them
 * @param options See {@link ParseAddressHeaderOptions}
 */
export declare function parseAddressHeader(value: string | string[] | null | undefined, options?: ParseAddressHeaderOptions): AddressObject;