From 591847539ae9d7ba121ec2e901abd4d1eed5f43b Mon Sep 17 00:00:00 2001 From: Damyan Mitev <damyan.mitev@vereign.com> Date: Thu, 13 Jun 2019 14:40:45 +0300 Subject: [PATCH] Add leaf field to part, add non leafs to returned parts from calculateParts --- javascript/src/helpers/mailparser.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/javascript/src/helpers/mailparser.js b/javascript/src/helpers/mailparser.js index 9bd873f..a6da68a 100644 --- a/javascript/src/helpers/mailparser.js +++ b/javascript/src/helpers/mailparser.js @@ -61,7 +61,7 @@ function calculateParts(body, from, to, previousBondary) { let boundary = findFirstBoundary(body, from, to); if (boundary == null) { - return [{ indices: { from: from, to: to }, boundary: previousBondary }]; + return [{ indices: { from: from, to: to }, boundary: previousBondary, leaf: true }]; } const realBoundary = boundary; @@ -78,6 +78,9 @@ function calculateParts(body, from, to, previousBondary) { } let bodies = []; + if (previousBondary !== null) { + bodies.push({indices: {from: from, to: to}, boundary: previousBondary, leaf: false}); + } for (let i = 0; i < boundaryIndicesLength - 1; i++) { const firstPair = boundaryPairs[i]; @@ -155,13 +158,14 @@ export function parseMIME(mime) { parts.push({ indices: { from: 0, to: mime.length, headersEnd: headersEnd }, headers, - boundary: "mimemessage" + boundary: "mimemessage", + leaf: false }); return parts; } -function getHeaderValue(header, part) { +export function getHeaderValue(header, part) { if (part.headers && part.headers[header] && part.headers[header].length) { return part.headers[header]; } -- GitLab