Skip to content

Commit

Permalink
resolves #204 - pull request to add reporting advice for incorrect mi…
Browse files Browse the repository at this point in the history
…me type headers
  • Loading branch information
lbod committed Nov 23, 2016
1 parent 5f8d607 commit 7c7d873
Show file tree
Hide file tree
Showing 4 changed files with 4,212 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/har/performance/mimeTypes.js
@@ -0,0 +1,23 @@
'use strict';
module.exports = {
id: 'mimeTypes',
title: 'Avoid using incorrect mime types',
description: 'It\'s not a great idea to let browsers guess content types (content sniffing), in some cases it can actually be a security risk.',
weight: 0,
tags: ['performance', 'bestpractice'],
processPage: function(page) {
let score = 100;
let offending = [];
page.assets.forEach(function(asset) {
if (asset.type == "other" && (asset.status >199 && asset.status < 300)) {
score--;
offending.push(asset.url);
}
});
return {
score: Math.max(0, score),
offending: offending,
advice: score < 100 ? 'The page has ' + offending.length + ' misconfigured mime type(s). ' : ''
};
}
};

0 comments on commit 7c7d873

Please sign in to comment.