|
@@ -10,6 +10,7 @@ var isWoff2 = require('is-woff2');
|
|
var isOtf = require('is-otf');
|
|
var isOtf = require('is-otf');
|
|
var isTtf = require('is-ttf');
|
|
var isTtf = require('is-ttf');
|
|
var isEot = require('is-eot');
|
|
var isEot = require('is-eot');
|
|
|
|
+var isJson = require('is-json');
|
|
|
|
|
|
var ContentTypeChecker = function() {
|
|
var ContentTypeChecker = function() {
|
|
|
|
|
|
@@ -57,7 +58,7 @@ var ContentTypeChecker = function() {
|
|
foundType = findContentType(entry.weightCheck.bodyBuffer);
|
|
foundType = findContentType(entry.weightCheck.bodyBuffer);
|
|
|
|
|
|
// If it's an image or a font, then rewrite.
|
|
// 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) {
|
|
if (foundType.type !== entry.type) {
|
|
debug('Content type %s is wrong for %s. It should be %s.', entry.type, entry.ulr, foundType.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;
|
|
return contentTypes.eot;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (isJson(bodyStr)) {
|
|
|
|
+ return contentTypes.json;
|
|
|
|
+ }
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -224,7 +229,16 @@ var ContentTypeChecker = function() {
|
|
entry.type = 'webfont';
|
|
entry.type = 'webfont';
|
|
entry.isWebFont = true;
|
|
entry.isWebFont = true;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ json: {
|
|
|
|
+ type: 'json',
|
|
|
|
+ mimes: ['application/json'],
|
|
|
|
+ updateFn: function(entry) {
|
|
|
|
+ entry.type = 'json';
|
|
|
|
+ entry.isJSON = true;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
return {
|
|
return {
|