Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change charset parameter value from "utf8" to "utf-8" in default cont… #330

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/health-check.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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