Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves #204 - pull request to add reporting advice for incorrect mi…
…me type headers
- Loading branch information
Showing
4 changed files
with
4,212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). ' : '' | ||
}; | ||
} | ||
}; |
Oops, something went wrong.