From b3d213699cf86b2cab13fedadc5e8124a76a4ee7 Mon Sep 17 00:00:00 2001 From: Manuel Spigolon Date: Sun, 13 Apr 2025 09:38:40 +0200 Subject: [PATCH] chore: micro optimization Signed-off-by: Manuel Spigolon --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 9a37da2..e6ff7c2 100644 --- a/index.js +++ b/index.js @@ -73,7 +73,7 @@ async function fastifyBasicAuth (fastify, opts) { const strictCredentials = opts.strictCredentials ?? true const useUtf8 = opts.utf8 ?? true const charset = useUtf8 ? 'utf-8' : 'ascii' - const authenticateHeader = getAuthenticateHeader(opts.authenticate, useUtf8) + const authenticateHeader = getAuthenticateHeaders(opts.authenticate, useUtf8) const header = opts.header?.toLowerCase() || 'authorization' const credentialsRE = strictCredentials @@ -132,7 +132,7 @@ async function fastifyBasicAuth (fastify, opts) { if (err.statusCode === 401) { const header = authenticateHeader(req) if (header) { - reply.header(...header) + reply.header(header[0], header[1]) } } next(err) @@ -143,7 +143,7 @@ async function fastifyBasicAuth (fastify, opts) { } } -function getAuthenticateHeader (authenticate, useUtf8) { +function getAuthenticateHeaders (authenticate, useUtf8) { const defaultHeaderName = 'WWW-Authenticate' if (!authenticate) return () => false if (authenticate === true) {