Skip to content

Commit

Permalink
feat: add charset=UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
gjbkz committed Sep 8, 2021
1 parent e91534f commit 9625202
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/defaultContentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export const defaultContentTypes = {
'image/tiff': ['.tiff'],
'image/heif': ['.heif'],
'image/heic': ['.heic'],
'text/javascript': ['.js'],
'text/javascript; charset=UTF-8': ['.js'],
'text/css': ['.css'],
'font/otf': ['.otf'],
'font/ttf': ['.ttf'],
'font/woff': ['.woff'],
'font/woff2': ['.woff2'],
'text/html': ['.html', '.htm'],
'text/plain': ['.txt', '.log'],
'text/html; charset=UTF-8': ['.html', '.htm'],
'text/plain; charset=UTF-8': ['.txt', '.log'],
'application/json': ['.json'],
'image/vnd.microsoft.icon': ['.ico'],
};
2 changes: 1 addition & 1 deletion src/middleware.reload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ ava('reload', async (t) => {
]);
t.like(addEvent, {data: 'index.html', event: 'add'});
t.is(indexRes.status, 200);
t.is(indexRes.headers.get('content-type'), 'text/html');
t.is(indexRes.headers.get('content-type'), 'text/html; charset=UTF-8');
const [changeEvent] = await Promise.all([
waitMessageChange('changeEvent'),
fs.promises.writeFile(indexFilePath, Buffer.from('<!doctype html>\nindex2')),
Expand Down
8 changes: 4 additions & 4 deletions src/middleware.static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ava.serial('GET /foo.txt', async (t) => {
const res = await fetch(`${url}`);
t.log(`${res.status} ${res.statusText}`);
t.is(res.status, 200);
t.is(res.headers.get('content-type'), 'text/plain');
t.is(res.headers.get('content-type'), 'text/plain; charset=UTF-8');
t.is(`${await res.text()}`, `${files['foo.txt']}`);
});

Expand All @@ -55,7 +55,7 @@ ava.serial('GET /', async (t) => {
const res = await fetch(`${url}`);
t.log(`${res.status} ${res.statusText}`);
t.is(res.status, 200);
t.is(res.headers.get('content-type'), 'text/html');
t.is(res.headers.get('content-type'), 'text/html; charset=UTF-8');
});

ava.serial('GET /bar/', async (t) => {
Expand All @@ -64,7 +64,7 @@ ava.serial('GET /bar/', async (t) => {
const res = await fetch(`${url}`);
t.log(`${res.status} ${res.statusText}`);
t.is(res.status, 200);
t.is(res.headers.get('content-type'), 'text/html');
t.is(res.headers.get('content-type'), 'text/html; charset=UTF-8');
const html = await res.text();
t.true(html.includes('baz1'));
t.true(html.includes('baz2'));
Expand All @@ -76,7 +76,7 @@ ava.serial('GET /middleware-static-livereload.js', async (t) => {
const res = await fetch(`${url}`);
t.log(`${res.status} ${res.statusText}`);
t.is(res.status, 200);
t.is(res.headers.get('content-type'), 'text/javascript');
t.is(res.headers.get('content-type'), 'text/javascript; charset=UTF-8');
});

ava.serial('GET /middleware-static-livereload.js/connect', async (t) => {
Expand Down

0 comments on commit 9625202

Please sign in to comment.