clarify minification logic
authoralexlamsl <alexlamsl@gmail.com>
Thu, 4 Feb 2016 20:05:30 +0000 (04:05 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Thu, 4 Feb 2016 20:11:04 +0000 (04:11 +0800)
dist/htmlminifier.js
src/htmlminifier.js

index 4f89c25..8ee18fa 100644 (file)
       return attrValue;
     }
     else if (isMetaViewport(tag, attrs) && attrName === 'content') {
-      attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(num) {
-        return (+num).toString();
+      attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(numString) {
+        // "0.90000" -> "0.9"
+        // "1.0" -> "1"
+        // "1.0001" -> "1.0001" (unchanged)
+        return (+numString).toString();
       });
     }
     else if (attrValue && options.customAttrCollapse && options.customAttrCollapse.test(attrName)) {
index cd0b304..b117859 100644 (file)
       return attrValue;
     }
     else if (isMetaViewport(tag, attrs) && attrName === 'content') {
-      attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(num) {
-        return (+num).toString();
+      attrValue = attrValue.replace(/\s+/g, '').replace(/[0-9]+\.[0-9]+/g, function(numString) {
+        // "0.90000" -> "0.9"
+        // "1.0" -> "1"
+        // "1.0001" -> "1.0001" (unchanged)
+        return (+numString).toString();
       });
     }
     else if (attrValue && options.customAttrCollapse && options.customAttrCollapse.test(attrName)) {