MCPcopy Create free account
hub / github.com/QLHazyCoder/FlowPilot / decodeMimeBody

Function decodeMimeBody

cloudflare-temp-email-utils.js:261–277  ·  view source on GitHub ↗
(bodyText = '', headers = {})

Source from the content-addressed store, hash-verified

259 }
260
261 function decodeMimeBody(bodyText = '', headers = {}) {
262 const contentType = String(headers['content-type'] || '');
263 const transferEncoding = String(headers['content-transfer-encoding'] || '').trim().toLowerCase();
264 const charset = getCharsetFromContentType(contentType);
265 let decoded = String(bodyText || '');
266
267 if (transferEncoding === 'base64') {
268 decoded = decodeBytesToString(base64ToBytes(decoded), charset);
269 } else if (transferEncoding === 'quoted-printable') {
270 decoded = decodeBytesToString(quotedPrintableToBytes(decoded), charset);
271 }
272
273 if (/text\/html/i.test(contentType)) {
274 return stripHtmlTags(decoded);
275 }
276 return decoded.replace(/\s+/g, ' ').trim();
277 }
278
279 function extractTextFromMime(rawMessage = '', depth = 0) {
280 const { headerText, bodyText } = splitRawMessage(rawMessage);

Callers 1

extractTextFromMimeFunction · 0.85

Calls 5

decodeBytesToStringFunction · 0.85
base64ToBytesFunction · 0.85
quotedPrintableToBytesFunction · 0.85
stripHtmlTagsFunction · 0.70

Tested by

no test coverage detected