From fce3d5e2faeb71ceaf922693aa78bedcfaabff85 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Fri, 5 Feb 2016 04:05:30 +0800 Subject: [PATCH] clarify minification logic --- dist/htmlminifier.js | 7 +++++-- src/htmlminifier.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 4f89c25..8ee18fa 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -857,8 +857,11 @@ 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)) { diff --git a/src/htmlminifier.js b/src/htmlminifier.js index cd0b304..b117859 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -292,8 +292,11 @@ 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)) { -- 2.34.1