瀏覽代碼

Fix type xml issue

Gaël Métais 10 年之前
父節點
當前提交
87adc575ac
共有 2 個文件被更改,包括 4 次插入1 次删除
  1. 3 0
      lib/tools/weightChecker/weightChecker.js
  2. 1 1
      test/core/weightCheckerTest.js

+ 3 - 0
lib/tools/weightChecker/weightChecker.js

@@ -155,6 +155,7 @@ var WeightChecker = function() {
         requests.forEach(function(req) {
             var weight = ((typeof req.weightCheck.bodySize === 'number') ? req.weightCheck.bodySize + req.weightCheck.headersSize : req.contentLength) || 0;
             var type = req.type || 'other';
+            type = (results.byType[type]) ? type : 'other';
 
             results.totalWeight += weight;
             results.byType[type].totalWeight += weight;
@@ -275,6 +276,8 @@ var WeightChecker = function() {
         requests.forEach(function(req) {
             if (req.url !== 'about:blank') {
                 var type = req.type || 'other';
+                type = (results.byType[type]) ? type : 'other';
+                
                 results.byType[type].push(req.url);
                 results.total ++;
             }

+ 1 - 1
test/core/weightCheckerTest.js

@@ -142,7 +142,7 @@ describe('weightChecker', function() {
 
             data.toolsResults.weightChecker.offenders.should.have.a.property('gzipCompression');
             data.toolsResults.weightChecker.offenders.gzipCompression.totalGain.should.be.above(0);
-            data.toolsResults.weightChecker.offenders.gzipCompression.files.length.should.equal(4);
+            data.toolsResults.weightChecker.offenders.gzipCompression.files.length.should.equal(5);
 
             data.toolsResults.weightChecker.offenders.should.have.a.property('fileMinification');
             data.toolsResults.weightChecker.offenders.fileMinification.totalGain.should.be.above(0);