Skip to content

Added charset=UTF-8 to content-type to fix encoding issues. #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ module.exports = function(compiler, options) {
var content = fs.readFileSync(filename);
content = handleRangeHeaders(content, req, res);
res.setHeader("Access-Control-Allow-Origin", "*"); // To support XHR, etc.
res.setHeader("Content-Type", mime.lookup(filename));
res.setHeader("Content-Type", mime.lookup(filename) + "; charset=UTF-8");
res.setHeader("Content-Length", content.length);
if(options.headers) {
for(var name in options.headers) {
Expand Down
8 changes: 4 additions & 4 deletions test/Server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("Server", function() {

it("GET request to bundle file", function(done) {
request(app).get("/public/bundle.js")
.expect("Content-Type", "application/javascript")
.expect("Content-Type", "application/javascript; charset=UTF-8")
.expect("Content-Length", "2780")
.expect("Access-Control-Allow-Origin", "*")
.expect(200, /console\.log\("Hey\."\)/, done);
Expand All @@ -57,7 +57,7 @@ describe("Server", function() {

it("request to image", function(done) {
request(app).get("/public/svg.svg")
.expect("Content-Type", "image/svg+xml")
.expect("Content-Type", "image/svg+xml; charset=UTF-8")
.expect("Content-Length", "4778")
.expect("Access-Control-Allow-Origin", "*")
.expect(200, done);
Expand All @@ -71,13 +71,13 @@ describe("Server", function() {

it("request to HMR json", function(done) {
request(app).get("/public/123a123412.hot-update.json")
.expect("Content-Type", "application/json")
.expect("Content-Type", "application/json; charset=UTF-8")
.expect(200, /\[\"hi\"\]/, done);
});

it("request to directory", function(done) {
request(app).get("/public/")
.expect("Content-Type", "text/html")
.expect("Content-Type", "text/html; charset=UTF-8")
.expect("Content-Length", "10")
.expect("Access-Control-Allow-Origin", "*")
.expect(200, /My\ Index\./, done);
Expand Down