Skip to content

Commit

Permalink
fix: Fix Chinese garbled.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 13, 2020
1 parent 2841ea2 commit bb39144
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default async (args: IServerArgs) => {
filePath = path.join(filePath, 'index.html');
pathname = path.join(pathname, 'index.html');
}
let fileStr = await fs.readFile(filePath, 'binary')
let fileStr = await fs.readFile(filePath, 'binary');
const ext = getExt(filePath);
sendFile(res, pathname, 200, ext === 'html' ? fileStr + reloadScript(reloadPort) : fileStr, ext);
}).listen(port);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const sendFile = (res: ServerResponse, resource: string, status: number,
"Content-Type": mime[ext] || "application/octet-stream",
"Access-Control-Allow-Origin": "*"
});
res.write(file);
res.write(file, 'binary');
res.end();
if (status !== 404) {
console.log(" \x1b[42m", status, "\x1b[0m", `${resource}`);
Expand Down

0 comments on commit bb39144

Please sign in to comment.