Skip to content

Commit d33f801

Browse files
authoredMay 11, 2017
Merge pull request #133 from xiaody/master
js/json should be utf-8 charset
2 parents 89d499e + aa327fe commit d33f801

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎build/test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ assert.equal('font/opentype', mime.lookup('file.otf'));
5151
//
5252

5353
assert.equal('UTF-8', mime.charsets.lookup('text/plain'));
54-
assert.equal(undefined, mime.charsets.lookup(mime.types.js));
54+
assert.equal('UTF-8', mime.charsets.lookup(mime.types.js));
55+
assert.equal('UTF-8', mime.charsets.lookup(mime.types.json));
56+
assert.equal(undefined, mime.charsets.lookup(mime.types.xml));
5557
assert.equal('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
5658

5759
console.log('\nAll tests passed');

‎mime.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mime.Mime = Mime;
101101
mime.charsets = {
102102
lookup: function(mimeType, fallback) {
103103
// Assume text types are utf8
104-
return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
104+
return (/^text\/|^application\/(javascript|json)/).test(mimeType) ? 'UTF-8' : fallback;
105105
}
106106
};
107107

0 commit comments

Comments
 (0)
Please sign in to comment.