Comparing version 0.0.8 to 0.0.9
@@ -100,6 +100,2 @@ /* | ||
function getBodyParts(content) { | ||
return content.split(/(\t|\n|\s)boundary=.*?$/gi); | ||
} | ||
function parseKeyValuePairs(keys, header) { | ||
@@ -159,37 +155,2 @@ | ||
function getBodyParts(body, contentTypeBoundaries) { | ||
if (contentTypeBoundaries.length === 0) | ||
return body.replace(/(\s+|\n+)$/g, ""); | ||
var bodyLines = body.split(/\n/g); | ||
var parts = [ | ||
[] | ||
]; | ||
var currentPartIndex = 0; | ||
for (var i in bodyLines) { | ||
for (var x = 0; x < contentTypeBoundaries.length; x++) { | ||
if (bodyLines[i].indexOf(contentTypeBoundaries[x]) !== -1) { | ||
currentPartIndex++; | ||
parts[currentPartIndex] = []; | ||
} else { | ||
var curIndex = parts[currentPartIndex].length - 1; | ||
if (parts[currentPartIndex][curIndex] !== bodyLines[i]) { | ||
var l = bodyLines[i]; | ||
for (var z in contentTypeBoundaries) { | ||
l = l.replace(eval("/^(-+|)" + escapeSpecialChars(contentTypeBoundaries[z]) + ".*?(\\n|$)/g"), ""); | ||
} | ||
parts[currentPartIndex].push(l); | ||
} | ||
} | ||
} | ||
} | ||
var items = _.map(parts, function (item) { | ||
return item.join("\n"); | ||
}) | ||
return items; | ||
} | ||
function parseBodyParts(body, contentTypeBoundaries) { | ||
@@ -199,3 +160,3 @@ var items = []; | ||
_.map(bodyParts, function (bodyPart) { | ||
var item = parseSingleBodyPart(bodyPart); | ||
var item = parseSingleBodyPart("Content-" + bodyPart); | ||
if ((Object.keys(item.headers).length > 0 && item.body.length > 0)) | ||
@@ -202,0 +163,0 @@ items.push(item); |
{ | ||
"name": "emlx2json", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "JSON parser for Apple Mail (Mail.app) messages (.emlx)", | ||
@@ -18,3 +18,3 @@ "dependencies": { | ||
"main": "lib/emlx2json.js", | ||
"_id": "emlx2json@0.0.8" | ||
"_id": "emlx2json@0.0.9" | ||
} |
235
5
9966
5