postal-mime
Advanced tools
Comparing version 2.2.0 to 2.2.1
# Changelog | ||
## [2.2.1](https://github.com/postalsys/postal-mime/compare/v2.2.0...v2.2.1) (2024-03-31) | ||
### Bug Fixes | ||
* **parser:** Reply-To value must be an array, not a single address object ([280bd8d](https://github.com/postalsys/postal-mime/commit/280bd8dc1626315e1a43f35641415453c434716e)) | ||
## [2.2.0](https://github.com/postalsys/postal-mime/compare/v2.1.2...v2.2.0) (2024-03-26) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "postal-mime", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Email parser for browser environments", | ||
@@ -5,0 +5,0 @@ "main": "./src/postal-mime.js", |
@@ -40,2 +40,3 @@ export type RawEmail = string | ArrayBuffer | Uint8Array | Blob | Buffer | ReadableStream; | ||
declare class PostalMime { | ||
static parse(email: RawEmail): Promise<Email>; | ||
parse(email: RawEmail): Promise<Email>; | ||
@@ -42,0 +43,0 @@ } |
@@ -7,2 +7,5 @@ # postal-mime | ||
> [!TIP] | ||
> PostalMime is developed by the makers of **[EmailEngine](https://emailengine.app/?utm_source=github&utm_campaign=imapflow&utm_medium=readme-link)** – a self-hosted email gateway that allows making **REST requests against IMAP and SMTP servers**. EmailEngine also sends webhooks whenever something changes on the registered accounts. | ||
## Source | ||
@@ -104,7 +107,7 @@ | ||
- **headers[].value** is the unprocessed value of the header line | ||
- **from**, **sender**, **replyTo** includes a processed object for the corresponding headers | ||
- **from**, **sender** includes a processed object for the corresponding headers | ||
- **from.name** is decoded name (empty string if not set) | ||
- **from.address** is the email address | ||
- **deliveredTo**, **returnPath** is the email address from the corresponding header | ||
- **to**, **cc**, **bcc** includes an array of processed objects for the corresponding headers | ||
- **to**, **cc**, **bcc**, **replyTo** includes an array of processed objects for the corresponding headers | ||
- **to[].name** is decoded name (empty string if not set) | ||
@@ -111,0 +114,0 @@ - **to[].address** is the email address |
@@ -361,12 +361,12 @@ import MimeNode from './mime-node.js'; | ||
let message = { | ||
const message = { | ||
headers: this.root.headers.map(entry => ({ key: entry.key, value: entry.value })).reverse() | ||
}; | ||
for (let key of ['from', 'sender', 'reply-to']) { | ||
let addressHeader = this.root.headers.find(line => line.key === key); | ||
for (const key of ['from', 'sender']) { | ||
const addressHeader = this.root.headers.find(line => line.key === key); | ||
if (addressHeader && addressHeader.value) { | ||
let addresses = addressParser(addressHeader.value); | ||
const addresses = addressParser(addressHeader.value); | ||
if (addresses && addresses.length) { | ||
message[key.replace(/\-(.)/g, (o, c) => c.toUpperCase())] = addresses[0]; | ||
message[key] = addresses[0]; | ||
} | ||
@@ -376,8 +376,9 @@ } | ||
for (let key of ['delivered-to', 'return-path']) { | ||
let addressHeader = this.root.headers.find(line => line.key === key); | ||
for (const key of ['delivered-to', 'return-path']) { | ||
const addressHeader = this.root.headers.find(line => line.key === key); | ||
if (addressHeader && addressHeader.value) { | ||
let addresses = addressParser(addressHeader.value); | ||
const addresses = addressParser(addressHeader.value); | ||
if (addresses && addresses.length && addresses[0].address) { | ||
message[key.replace(/\-(.)/g, (o, c) => c.toUpperCase())] = addresses[0].address; | ||
const camelKey = key.replace(/\-(.)/g, (o, c) => c.toUpperCase()); | ||
message[camelKey] = addresses[0].address; | ||
} | ||
@@ -387,4 +388,4 @@ } | ||
for (let key of ['to', 'cc', 'bcc']) { | ||
let addressHeaders = this.root.headers.filter(line => line.key === key); | ||
for (const key of ['to', 'cc', 'bcc', 'reply-to']) { | ||
const addressHeaders = this.root.headers.filter(line => line.key === key); | ||
let addresses = []; | ||
@@ -398,10 +399,12 @@ | ||
if (addresses && addresses.length) { | ||
message[key] = addresses; | ||
const camelKey = key.replace(/\-(.)/g, (o, c) => c.toUpperCase()); | ||
message[camelKey] = addresses; | ||
} | ||
} | ||
for (let key of ['subject', 'message-id', 'in-reply-to', 'references']) { | ||
let header = this.root.headers.find(line => line.key === key); | ||
for (const key of ['subject', 'message-id', 'in-reply-to', 'references']) { | ||
const header = this.root.headers.find(line => line.key === key); | ||
if (header && header.value) { | ||
message[key.replace(/\-(.)/g, (o, c) => c.toUpperCase())] = decodeWords(header.value); | ||
const camelKey = key.replace(/\-(.)/g, (o, c) => c.toUpperCase()); | ||
message[camelKey] = decodeWords(header.value); | ||
} | ||
@@ -408,0 +411,0 @@ } |
128996
3800
131