@bobfrankston/mailx-imap 0.1.63 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +14 -2
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -113,8 +113,20 @@ async function extractPreview(source) {
|
|
|
113
113
|
const parsed = await parseSerial(fixCharsetDeclString(source), "background");
|
|
114
114
|
const bodyText = parsed.text || "";
|
|
115
115
|
const bodyHtml = parsed.html || "";
|
|
116
|
-
//
|
|
117
|
-
|
|
116
|
+
// Prefer HTML so we can replace <img> with [image] before tag-strip;
|
|
117
|
+
// fall back to text if no HTML part. Either source then gets any
|
|
118
|
+
// remaining base64 data: URIs (rare: text/plain copies generated
|
|
119
|
+
// from a Quill compose pasted-image HTML) collapsed to [image] too.
|
|
120
|
+
let raw;
|
|
121
|
+
if (bodyHtml) {
|
|
122
|
+
raw = bodyHtml
|
|
123
|
+
.replace(/<img\b[^>]*>/gi, " [image] ")
|
|
124
|
+
.replace(/<[^>]+>/g, " ");
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
raw = bodyText;
|
|
128
|
+
}
|
|
129
|
+
raw = raw.replace(/data:image\/[a-z0-9.+-]+;base64,[A-Za-z0-9+/=\s]+/gi, "[image]");
|
|
118
130
|
const preview = decodeEntities(raw).replace(/\s+/g, " ").trim().slice(0, 200);
|
|
119
131
|
const hasAttachments = (parsed.attachments?.length || 0) > 0;
|
|
120
132
|
return { bodyHtml, bodyText, preview, hasAttachments };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bobfrankston/mailx-imap",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.64",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@bobfrankston/mailx-types": "^0.1.18",
|
|
13
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
13
|
+
"@bobfrankston/mailx-settings": "^0.1.24",
|
|
14
14
|
"@bobfrankston/mailx-store": "^0.1.37",
|
|
15
15
|
"@bobfrankston/iflow-direct": "^0.1.50",
|
|
16
16
|
"@bobfrankston/tcp-transport": "^0.1.6",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
".transformedSnapshot": {
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@bobfrankston/mailx-types": "^0.1.18",
|
|
41
|
-
"@bobfrankston/mailx-settings": "^0.1.
|
|
41
|
+
"@bobfrankston/mailx-settings": "^0.1.24",
|
|
42
42
|
"@bobfrankston/mailx-store": "^0.1.37",
|
|
43
43
|
"@bobfrankston/iflow-direct": "^0.1.50",
|
|
44
44
|
"@bobfrankston/tcp-transport": "^0.1.6",
|