diff --git a/lib/tools/redownload/contentTypeChecker.js b/lib/tools/redownload/contentTypeChecker.js index 58fb3df..ea06d88 100644 --- a/lib/tools/redownload/contentTypeChecker.js +++ b/lib/tools/redownload/contentTypeChecker.js @@ -10,6 +10,7 @@ var isWoff2 = require('is-woff2'); var isOtf = require('is-otf'); var isTtf = require('is-ttf'); var isEot = require('is-eot'); +var isJson = require('is-json'); var ContentTypeChecker = function() { @@ -57,7 +58,7 @@ var ContentTypeChecker = function() { foundType = findContentType(entry.weightCheck.bodyBuffer); // If it's an image or a font, then rewrite. - if (foundType !== null && (foundType.type === 'image' || foundType.type === 'webfont')) { + if (foundType !== null && (foundType.type === 'image' || foundType.type === 'webfont' || foundType.type === 'json')) { if (foundType.type !== entry.type) { debug('Content type %s is wrong for %s. It should be %s.', entry.type, entry.ulr, foundType.type); } @@ -119,6 +120,10 @@ var ContentTypeChecker = function() { return contentTypes.eot; } + if (isJson(bodyStr)) { + return contentTypes.json; + } + return null; } @@ -224,7 +229,16 @@ var ContentTypeChecker = function() { entry.type = 'webfont'; entry.isWebFont = true; } - } + }, + json: { + type: 'json', + mimes: ['application/json'], + updateFn: function(entry) { + entry.type = 'json'; + entry.isJSON = true; + } + }, + }; return { diff --git a/package.json b/package.json index ed35943..2d76827 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yellowlabtools", - "version": "2.0.0-beta", + "version": "2.0.0", "description": "Online tool to audit a webpage for performance and front-end quality issues", "license": "GPL-2.0", "author": { @@ -50,6 +50,7 @@ "is-eot": "1.0.0", "is-gif": "3.0.0", "is-jpg": "2.0.0", + "is-json": "2.0.1", "is-otf": "0.1.2", "is-png": "1.1.0", "is-svg": "3.0.0",