Skip to content

Commit

Permalink
Merge pull request #133 from xiaody/master
Browse files Browse the repository at this point in the history
js/json should be utf-8 charset
  • Loading branch information
broofa authored May 11, 2017
2 parents 89d499e + aa327fe commit d33f801
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 d33f801

Please sign in to comment.