Skip to content

Commit

Permalink
Updated stripHTML and test to strip style from html
Browse files Browse the repository at this point in the history
  • Loading branch information
RGBboy committed Sep 13, 2012
1 parent 9c3bbc0 commit 9964a79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/helpers.js
Expand Up @@ -21,6 +21,9 @@ module.exports.stripHTML = stripHTML;
function stripHTML(str){
str = (str || "").toString("utf-8").trim();

// remove style
str = str.replace(/<style[\s\S]{1,}?\/style>/gi, '');

// replace newlines
str = str.replace(/\r?\n|\r/g,"-\u0002\u0002-");

Expand Down
2 changes: 1 addition & 1 deletion test/nodemailer.js
Expand Up @@ -12,7 +12,7 @@ exports["General tests"] = {

"stripHTML": function(test){

var html = "<h1>Tere &raquo;</h1><ul><li>Test</li></ul>",
var html = "<style>h1{color:#fe57a1}</style><h1>Tere &raquo;</h1><ul><li>Test</li></ul>",
output = "Tere »\n======\n\n * Test";

test.equal(stripHTML(html).trim(), output);
Expand Down

0 comments on commit 9964a79

Please sign in to comment.