mailparser
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -26,8 +26,7 @@ 'use strict'; | ||
constructor(config) { | ||
let options = { | ||
super({ | ||
readableObjectMode: true, | ||
writableObjectMode: false, | ||
skipTextToHtml: false | ||
}; | ||
super(options); | ||
}); | ||
@@ -828,2 +827,6 @@ this.options = config || {}; | ||
if (this.options.skipImageLinks) { | ||
return done(null, html); | ||
} | ||
html.replace(/\bcid:([^'"\s]{1,256})/g, (match, cid) => { | ||
@@ -883,25 +886,28 @@ for (let i = 0, len = this.attachmentList.length; i < len; i++) { | ||
try { | ||
if (linkify.pretest(encoded)) { | ||
let links = linkify.match(encoded) || []; | ||
let result = []; | ||
let last = 0; | ||
if (!this.options.skipTextLinks) { | ||
try { | ||
if (linkify.pretest(encoded)) { | ||
let links = linkify.match(encoded) || []; | ||
let result = []; | ||
let last = 0; | ||
links.forEach(link => { | ||
if (last < link.index) { | ||
result.push(encoded.slice(last, link.index)); | ||
} | ||
links.forEach(link => { | ||
if (last < link.index) { | ||
result.push(encoded.slice(last, link.index)); | ||
} | ||
result.push(`<a href="${link.url}">${link.text}</a>`); | ||
result.push(`<a href="${link.url}">${link.text}</a>`); | ||
last = link.lastIndex; | ||
}); | ||
last = link.lastIndex; | ||
}); | ||
result.push(encoded.slice(last)); | ||
result.push(encoded.slice(last)); | ||
encoded = result.join(''); | ||
encoded = result.join(''); | ||
} | ||
} catch (E) { | ||
// failed, don't linkify | ||
} | ||
} catch (E) { | ||
// failed, don't linkify | ||
} | ||
let text = | ||
@@ -908,0 +914,0 @@ '<p>' + |
@@ -25,3 +25,3 @@ 'use strict'; | ||
let parser = new MailParser(); | ||
let parser = new MailParser(options); | ||
@@ -28,0 +28,0 @@ parser.on('headers', headers => { |
{ | ||
"name": "mailparser", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "Parse e-mails", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
51400
964