Skip to content

Commit

Permalink
refactor: use lowercase for charset (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Nov 18, 2024
1 parent 396f0aa commit 6f078bb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const server = http.createServer(async function onRequest (req, res) {
// get directory list
const list = await readdir(metadata.path)
// render an index for the directory
res.writeHead(200, { 'Content-Type': 'text/plain; charset=UTF-8' })
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' })
res.end(list.join('\n') + '\n')
} else {
res.writeHead(statusCode, headers)
Expand Down
6 changes: 3 additions & 3 deletions lib/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ function sendError (statusCode, err) {
const doc = ERROR_RESPONSES[statusCode]

// basic response
headers['Content-Type'] = 'text/html; charset=UTF-8'
headers['Content-Type'] = 'text/html; charset=utf-8'
headers['Content-Length'] = doc[1]
headers['Content-Security-Policy'] = "default-src 'none'"
headers['X-Content-Type-Options'] = 'nosniff'
Expand Down Expand Up @@ -492,7 +492,7 @@ function sendFileDirectly (request, path, stat, options) {
let type = mime.getType(path) || mime.default_type
debug('content-type %s', type)
if (type && isUtf8MimeType(type)) {
type += '; charset=UTF-8'
type += '; charset=utf-8'
}
if (type) {
headers['Content-Type'] = type
Expand Down Expand Up @@ -597,7 +597,7 @@ function sendRedirect (path, options) {
const doc = createHtmlDocument('Redirecting', 'Redirecting to ' + escapeHtml(loc))

const headers = {}
headers['Content-Type'] = 'text/html; charset=UTF-8'
headers['Content-Type'] = 'text/html; charset=utf-8'
headers['Content-Length'] = doc[1]
headers['Content-Security-Policy'] = "default-src 'none'"
headers['X-Content-Type-Options'] = 'nosniff'
Expand Down
2 changes: 1 addition & 1 deletion test/mime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('send.mime', function (t) {

request(createServer({ root: fixtures }))
.get('/no_ext')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(200, err => t.error(err))
})

Expand Down
4 changes: 2 additions & 2 deletions test/send.2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ test('send(file)', function (t) {

request(app)
.get('/name.txt')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(200, function (err) {
t.error(err)
request(app)
.get('/tobi.html')
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect('Content-Type', 'text/html; charset=utf-8')
.expect(200, err => t.error(err))
})
})
Expand Down
4 changes: 2 additions & 2 deletions test/send.3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ test('send(file)', function (t) {
const { statusCode, headers, stream, type, metadata } = await send(req, req.url, { root: fixtures })
if (type === 'directory') {
const list = await readdir(metadata.path)
res.writeHead(200, { 'Content-Type': 'text/plain; charset=UTF-8' })
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' })
res.end(list.join('\n') + '\n')
} else {
res.writeHead(statusCode, headers)
Expand All @@ -89,7 +89,7 @@ test('send(file)', function (t) {

request(app)
.get('/pets')
.expect('Content-Type', 'text/plain; charset=UTF-8')
.expect('Content-Type', 'text/plain; charset=utf-8')
.expect(200, '.hidden\nindex.html\n', err => t.error(err))
})

Expand Down

0 comments on commit 6f078bb

Please sign in to comment.