Comparing version 5.2.0 to 5.3.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
const PassThrough = require('stream').PassThrough; | ||
const pathlib = require('path'); | ||
@@ -66,2 +67,4 @@ class MimeNode { | ||
this._parsedContentDisposition = this.libmime.parseHeaderValue(this.headers.getFirst('Content-Disposition')); | ||
// if content-type is missing default to plaintext | ||
@@ -72,3 +75,14 @@ let contentHeader; | ||
} else { | ||
contentHeader = 'text/plain'; | ||
if (this._parsedContentDisposition.params.filename) { | ||
let extension = pathlib.parse(this._parsedContentDisposition.params.filename).ext.replace(/^\./, ''); | ||
if (extension) { | ||
contentHeader = libmime.detectMimeType(extension); | ||
} | ||
} | ||
if (!contentHeader && /^attachment$/i.test(this._parsedContentDisposition.value)) { | ||
contentHeader = 'application/octet-stream'; | ||
} else { | ||
contentHeader = 'text/plain'; | ||
} | ||
} | ||
@@ -78,4 +92,2 @@ | ||
this._parsedContentDisposition = this.libmime.parseHeaderValue(this.headers.getFirst('Content-Disposition')); | ||
this.encoding = this.headers | ||
@@ -82,0 +94,0 @@ .getFirst('Content-Transfer-Encoding') |
{ | ||
"name": "mailsplit", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"description": "Split email messages into an object stream", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "7.32.0", | ||
"eslint": "8.0.0", | ||
"eslint-config-nodemailer": "1.2.0", | ||
@@ -26,3 +26,3 @@ "eslint-config-prettier": "8.3.0", | ||
"grunt-cli": "1.4.3", | ||
"grunt-contrib-nodeunit": "3.0.0", | ||
"grunt-contrib-nodeunit": "4.0.0", | ||
"grunt-eslint": "23.0.0", | ||
@@ -29,0 +29,0 @@ "random-message": "1.1.0" |
69782
1151