From e784689265913f19162adf5fce32a51782801549 Mon Sep 17 00:00:00 2001 From: Bryan Rayner Date: Fri, 25 Sep 2015 10:48:53 -0500 Subject: [PATCH] Add support for carriage returns --- src/htmlminifier.js | 2 +- tests/minifier.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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"' + -- 2.34.1