From ef26873f59d67a5584459798d7b9001524df579e Mon Sep 17 00:00:00 2001 From: Frederic Heath-Renn Date: Mon, 19 Feb 2024 13:25:58 +0000 Subject: [PATCH] Change charset parameter value from "utf8" to "utf-8" in default content-type headers --- lib/health-check.js | 2 +- lib/invoker.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/health-check.js b/lib/health-check.js index 08fc811..4f696bf 100644 --- a/lib/health-check.js +++ b/lib/health-check.js @@ -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')); } diff --git a/lib/invoker.js b/lib/invoker.js index 361a5ad..e8ab08c 100644 --- a/lib/invoker.js +++ b/lib/invoker.js @@ -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': '*' @@ -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; } @@ -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;