Skip to content

Commit

Permalink
fix: Change charset parameter value from "utf8" to "utf-8" in default…
Browse files Browse the repository at this point in the history
… content-type headers (#330)
  • Loading branch information
flaheathrenn committed Feb 20, 2024
1 parent 4a2d964 commit ed9e7df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/health-check.js
Expand Up @@ -19,7 +19,7 @@ const livenessURL = process.env.LIVENESS_URL || LIVENESS_URL;
const protect = protection('http', protectCfg);

function callProtect(request, reply) {
reply.header('Content-Type', 'text/plain; charset=utf8');
reply.header('Content-Type', 'text/plain; charset=utf-8');
protect(request, reply, _ => reply.send('OK'));
}

Expand Down
10 changes: 5 additions & 5 deletions lib/invoker.js
Expand Up @@ -10,7 +10,7 @@ module.exports = function invoker(func) {
code: 200,
response: undefined,
headers: {
'content-type': 'application/json; charset=utf8',
'content-type': 'application/json; charset=utf-8',
'access-control-allow-methods':
'OPTIONS, GET, DELETE, POST, PUT, HEAD, PATCH',
'access-control-allow-origin': '*'
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = function invoker(func) {
// If the function returns a string, set the content type to text/plain
// and return it as the response
if (typeof fnReturn === 'string') {
payload.headers['content-type'] = 'text/plain; charset=utf8';
payload.headers['content-type'] = 'text/plain; charset=utf-8';
payload.response = fnReturn;
return payload;
}
Expand All @@ -97,15 +97,15 @@ module.exports = function invoker(func) {
// Provide default content-type unless supplied by user
if (!payload.headers || !payload.headers['content-type']) {
if (typeof fnReturn.body === 'string') {
payload.headers['content-type'] = 'text/plain; charset=utf8';
payload.headers['content-type'] = 'text/plain; charset=utf-8';
} else if (typeof fnReturn.body === 'object') {
payload.headers['content-type'] = 'application/json; charset=utf8';
payload.headers['content-type'] = 'application/json; charset=utf-8';
}
}
payload.response = fnReturn.body;
} else if (typeof fnReturn === 'object' && !fnReturn?.body) {
// Finally, the user may have supplied a simple object response
payload.headers['content-type'] = 'application/json; charset=utf8';
payload.headers['content-type'] = 'application/json; charset=utf-8';
payload.response = fnReturn;
}
return payload;
Expand Down

0 comments on commit ed9e7df

Please sign in to comment.