Skip to content

Commit

Permalink
added support for serving svg (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbalestra authored and matteofigus committed Jul 1, 2016
1 parent 417648c commit c33dbf1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/utils/get-mime-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ module.exports = function(extension){
return {
'.js': 'application/javascript',
'.css': 'text/css',
'.map': 'application/json',
'.gif': 'image/gif',
'.jpg': 'image/jpeg',
'.map': 'application/json',
'.png': 'image/png'
'.png': 'image/png',
'.svg': 'image/svg+xml'
}[extension];
};
57 changes: 54 additions & 3 deletions test/unit/utils-get-mime-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,61 @@ describe('utils : getMimeType', function(){
var getMimeType = require('../../src/utils/get-mime-type');

describe('when extension is known', function(){
var mimeType = getMimeType('.js');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('application/javascript');
describe('and extension is .js', function(){
var mimeType = getMimeType('.js');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('application/javascript');
});
});

describe('and extension is .css', function(){
var mimeType = getMimeType('.css');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('text/css');
});
});

describe('and extension is .gif', function(){
var mimeType = getMimeType('.gif');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('image/gif');
});
});

describe('and extension is .jpg', function(){
var mimeType = getMimeType('.jpg');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('image/jpeg');
});
});

describe('and extension is .map', function(){
var mimeType = getMimeType('.map');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('application/json');
});
});

describe('and extension is .png', function(){
var mimeType = getMimeType('.png');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('image/png');
});
});

describe('and extension is .svg', function(){
var mimeType = getMimeType('.svg');

it('should return the correct myme type', function(){
expect(mimeType).to.equal('image/svg+xml');
});
});
});

Expand Down

0 comments on commit c33dbf1

Please sign in to comment.