From 9af3316d8c51641a3fbc243ba986b888edbd50d3 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Fri, 22 Nov 2024 10:59:07 +0000 Subject: [PATCH] refactor: use lowercase for charset (#483) * refactor: use lowercase for charset * test: update charset for send update --- index.js | 2 +- test/content-type.test.js | 12 ++++++------ test/static.test.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index e7c20717..119a50f3 100644 --- a/index.js +++ b/index.js @@ -472,7 +472,7 @@ function getContentType (path) { if (!send.isUtf8MimeType(type)) { return type } - return `${type}; charset=UTF-8` + return `${type}; charset=utf-8` } function findIndexFile (pathname, root, indexFiles = ['index.html']) { diff --git a/test/content-type.test.js b/test/content-type.test.js index 80a124c7..4e012602 100644 --- a/test/content-type.test.js +++ b/test/content-type.test.js @@ -33,7 +33,7 @@ test('register /content-type', t => { url: 'http://localhost:' + fastify.server.address().port + '/content-type/index.html' }, (err, response) => { t.error(err) - t.equal(response.headers['content-type'], 'text/html; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') }) }) @@ -44,7 +44,7 @@ test('register /content-type', t => { url: 'http://localhost:' + fastify.server.address().port + '/content-type/index.css' }, (err, response) => { t.error(err) - t.equal(response.headers['content-type'], 'text/css; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/css; charset=utf-8') }) }) @@ -66,7 +66,7 @@ test('register /content-type', t => { url: 'http://localhost:' + fastify.server.address().port + '/content-type/test.txt' }, (err, response) => { t.error(err) - t.equal(response.headers['content-type'], 'text/plain; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/plain; charset=utf-8') }) }) @@ -111,7 +111,7 @@ test('register /content-type preCompressed', t => { } }, (err, response) => { t.error(err) - t.equal(response.headers['content-type'], 'text/html; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') }) }) @@ -125,7 +125,7 @@ test('register /content-type preCompressed', t => { } }, (err, response) => { t.error(err) - t.equal(response.headers['content-type'], 'text/css; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/css; charset=utf-8') }) }) @@ -153,7 +153,7 @@ test('register /content-type preCompressed', t => { } }, (err, response) => { t.error(err) - t.equal(response.headers['content-type'], 'text/plain; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/plain; charset=utf-8') }) }) diff --git a/test/static.test.js b/test/static.test.js index 45e2663d..60894909 100644 --- a/test/static.test.js +++ b/test/static.test.js @@ -4017,7 +4017,7 @@ t.test('content-length in head route should not return zero when using wildcard' }, (err, response, body) => { t.error(err) t.equal(response.statusCode, 200) - t.equal(response.headers['content-type'], 'text/html; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') t.equal(response.headers['content-length'], contentLength) t.equal(body.toString(), '') }) @@ -4055,7 +4055,7 @@ t.test('respect the .code when using with sendFile', t => { }, (err, response, body) => { t.error(err) t.equal(response.statusCode, 404) - t.equal(response.headers['content-type'], 'text/html; charset=UTF-8') + t.equal(response.headers['content-type'], 'text/html; charset=utf-8') t.equal(response.headers['content-length'], contentLength) t.equal(body.toString(), '') })