diff --git a/index.js b/index.js index 5cfa439..dad53fd 100644 --- a/index.js +++ b/index.js @@ -150,7 +150,7 @@ function createServer() { .toString() .replace('', HMR_SCRIPT + '') - res.setHeader('content-length', code.length) + res.setHeader('content-length', Buffer.byteLength(code)) } else { res.setHeader('content-length', stat.size) } @@ -173,7 +173,7 @@ function createServer() { res.setHeader('accept-ranges', 'bytes') res.setHeader('content-type', MIME_TYPES.html) - res.setHeader('content-length', code.length) + res.setHeader('content-length', Buffer.byteLength(code)) res.writeHead(200, 'OK') res.end(code) diff --git a/package.json b/package.json index 4b65422..5b9046b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "simple-http", "displayName": "simple http", "description": "🔥 简单的http服务器, 方便临时调试html", - "version": "1.5.0", + "version": "1.5.1", "publisher": "yutent", "author": "Yutent [@yutent]", "icon": "logo.png",