From: Bryan Rayner Date: Fri, 25 Sep 2015 15:48:53 +0000 (-0500) Subject: Add support for carriage returns X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=e784689265913f19162adf5fce32a51782801549;p=html-minifier.git Add support for carriage returns --- diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 28c8bc2..c9b4907 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -275,7 +275,7 @@ attrValue = attrValue.replace(/1\.0/g, '1').replace(/\s+/g, ''); } else if (attrValue && options.customAttrCollapse && options.customAttrCollapse.test(attrName)) { - attrValue = attrValue.replace(/\n+/g, ''); + attrValue = attrValue.replace(/\n+|\r+|\s{2,}/g, ''); } return attrValue; } diff --git a/tests/minifier.js b/tests/minifier.js index 458204d..47cf56f 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -1272,6 +1272,16 @@ equal(minify( input, { customAttrCollapse: /.+/ }), output); }); + test('custom attribute collapse with newlines, whitespace, and carriage returns', function(){ + input = '
'; + output = '
'; + + equal(minify( input, {customAttrCollapse: '/ng\-class/'}), output); + }); + test('do not escape attribute value', function() { input = '
\n"' +