Skip to content

Commit

Permalink
Serve JS files as utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Dec 5, 2017
1 parent 51f3bca commit 3d1c4cc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/middleware/serveFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function serveFile(req, res, next) {
// Cache modules for 1 year.
res
.set({
"Content-Type": contentType,
"Content-Type": `${contentType}; charset=utf-8`,
"Content-Length": Buffer.byteLength(code),
"Cache-Control": "public, max-age=31536000",
"Cache-Tag": "file,js-file,js-module"
Expand All @@ -91,9 +91,10 @@ function serveFile(req, res, next) {
const tags = ["file"]

const ext = path.extname(req.filename).substr(1)

if (ext) tags.push(`${ext}-file`)

if (contentType === "application/javascript") contentType += "; charset=utf-8"

// Cache files for 1 year.
res.set({
"Content-Type": contentType,
Expand Down

0 comments on commit 3d1c4cc

Please sign in to comment.