Skip to content

Commit

Permalink
Merge pull request #309 from macbre/webp-content-type
Browse files Browse the repository at this point in the history
requestMonitor: improvements
  • Loading branch information
macbre committed May 13, 2014
2 parents 2930609 + addf263 commit 90aa775
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/modules/requestsMonitor/requestsMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ exports.module = function(phantomas) {
case 'content-type':
// parse header value
var value = header.value.split(';').shift().toLowerCase();
entry.contentType = value;

switch(value) {
case 'text/html':
Expand Down Expand Up @@ -195,6 +196,7 @@ exports.module = function(phantomas) {
case 'image/jpeg':
case 'image/gif':
case 'image/svg+xml':
case 'image/webp':
entry.type = 'image';
entry.isImage = true;
break;
Expand Down
8 changes: 8 additions & 0 deletions test/modules/requestsMonitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ vows.describe('requestMonitor').addBatch({
'isBase64 is set': assertField('isBase64', true)
},
}).addBatch({
'content type is properly passed': {
topic: recvContentType('text/html'),
'entry.contentType is set': assertField('contentType', 'text/html')
},
'HTML is properly detected': {
topic: recvContentType('text/html'),
'isHTML is set': assertField('isHTML', true)
Expand Down Expand Up @@ -134,6 +138,10 @@ vows.describe('requestMonitor').addBatch({
topic: recvContentType('image/svg+xml'),
'isImage is set': assertField('isImage', true)
},
'WEBP image is properly detected': {
topic: recvContentType('image/webp'),
'isImage is set': assertField('isImage', true)
},
'Web font is properly detected (via MIME)': {
topic: recvContentType('application/font-woff'),
'isWebFont is set': assertField('isWebFont', true)
Expand Down

0 comments on commit 90aa775

Please sign in to comment.