mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 12:57:47 +00:00
[cli] add charset to content-type headers for vc dev (#9364)
Adds `charset: utf8` to the `content-type` header
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { lookup as lookupMimeType } from 'mime-types';
|
||||
import { contentType } from 'mime-types';
|
||||
|
||||
export default function getMimeType(fileName: string) {
|
||||
return lookupMimeType(fileName) || 'application/octet-stream';
|
||||
return contentType(fileName) || 'application/octet-stream';
|
||||
}
|
||||
|
||||
@@ -1129,10 +1129,10 @@ export default class DevServer {
|
||||
});
|
||||
body = `${json}\n`;
|
||||
} else if (accept.includes('html')) {
|
||||
res.setHeader('content-type', 'text/html');
|
||||
res.setHeader('content-type', 'text/html; charset=utf-8');
|
||||
body = redirectTemplate({ location, statusCode });
|
||||
} else {
|
||||
res.setHeader('content-type', 'text/plain');
|
||||
res.setHeader('content-type', 'text/plain; charset=utf-8');
|
||||
body = `Redirecting to ${location} (${statusCode})\n`;
|
||||
}
|
||||
res.end(body);
|
||||
|
||||
@@ -686,6 +686,7 @@ test('[vercel dev] should support static files with zero config', async () => {
|
||||
expect(body).toEqual('bye:user');
|
||||
|
||||
res = await fetch(`http://localhost:${port}/`);
|
||||
expect(res.headers.get('content-type')).toBe('text/html; charset=utf-8');
|
||||
body = await res.text();
|
||||
expect(body.startsWith('<h1>goodbye world</h1>')).toBeTruthy();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user