Add support for carriage returns
authorBryan Rayner <bryanerayner@gmail.com>
Fri, 25 Sep 2015 15:48:53 +0000 (10:48 -0500)
committerBryan Rayner <bryanerayner@gmail.com>
Fri, 25 Sep 2015 15:48:53 +0000 (10:48 -0500)
src/htmlminifier.js
tests/minifier.js

index 28c8bc2..c9b4907 100644 (file)
       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;
   }
index 458204d..47cf56f 100644 (file)
     equal(minify( input, { customAttrCollapse: /.+/ }), output);
   });
 
+  test('custom attribute collapse with newlines, whitespace, and carriage returns', function(){
+    input = '<div ng-class="{ \n\r' + 
+            '               value:true, \n\r'+
+            '               value2:false \n\r' + 
+            '               }"></div>';
+    output = '<div ng-class="{value:true,value2:false}"></div>';
+
+    equal(minify( input, {customAttrCollapse: '/ng\-class/'}), output);
+  });
+
   test('do not escape attribute value', function() {
     input = '<div data=\'{\n' +
     '\t"element": "<div class=\"test\"></div>\n"' +