Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #103 from RGBboy/master

Updated .stripHTML() and test to strip style from html
  • Loading branch information...
commit 8d49e10abe3dd575e4f2a819eaf367c970ca9799 2 parents 9c3bbc0 + e7d6479
@andris9 andris9 authored
Showing with 4 additions and 1 deletion.
  1. +3 −0  lib/helpers.js
  2. +1 −1  test/nodemailer.js
View
3  lib/helpers.js
@@ -21,6 +21,9 @@ module.exports.stripHTML = stripHTML;
function stripHTML(str){
str = (str || "").toString("utf-8").trim();
+ // remove head
+ str = str.replace(/<head[\s\S]{1,}?\/head>/gi, '');
+
// replace newlines
str = str.replace(/\r?\n|\r/g,"-\u0002\u0002-");
View
2  test/nodemailer.js
@@ -12,7 +12,7 @@ exports["General tests"] = {
"stripHTML": function(test){
- var html = "<h1>Tere &raquo;</h1><ul><li>Test</li></ul>",
+ var html = "<html><head><title>Title</title><style>h1{color:#fe57a1}</style></head><body><h1>Tere &raquo;</h1><ul><li>Test</li></ul></body></html>",
output = "Tere »\n======\n\n * Test";
test.equal(stripHTML(html).trim(), output);
Please sign in to comment.
Something went wrong with that request. Please try again.