Skip to content

Commit

Permalink
js/json should be utf-8 charset
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaody committed Oct 23, 2015
1 parent 6c3d324 commit aa327fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ assert.equal('font/opentype', mime.lookup('file.otf'));
//

assert.equal('UTF-8', mime.charsets.lookup('text/plain'));
assert.equal(undefined, mime.charsets.lookup(mime.types.js));
assert.equal('UTF-8', mime.charsets.lookup(mime.types.js));
assert.equal('UTF-8', mime.charsets.lookup(mime.types.json));
assert.equal(undefined, mime.charsets.lookup(mime.types.xml));
assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));

console.log('\nAll tests passed');
2 changes: 1 addition & 1 deletion mime.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ mime.Mime = Mime;
mime.charsets = {
lookup: function(mimeType, fallback) {
// Assume text types are utf8
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
return (/^text\/|^application\/(javascript|json)/).test(mimeType) ? 'UTF-8' : fallback;
}
};

Expand Down

0 comments on commit aa327fe

Please sign in to comment.