Skip to content

Commit 0db8a6d

Browse files
authored
perf: micro optimization (#166)
Signed-off-by: Manuel Spigolon <manuel.spigolon@nearform.com>
1 parent 5402518 commit 0db8a6d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async function fastifyBasicAuth (fastify, opts) {
7373
const strictCredentials = opts.strictCredentials ?? true
7474
const useUtf8 = opts.utf8 ?? true
7575
const charset = useUtf8 ? 'utf-8' : 'ascii'
76-
const authenticateHeader = getAuthenticateHeader(opts.authenticate, useUtf8)
76+
const authenticateHeader = getAuthenticateHeaders(opts.authenticate, useUtf8)
7777
const header = opts.header?.toLowerCase() || 'authorization'
7878

7979
const credentialsRE = strictCredentials
@@ -132,7 +132,7 @@ async function fastifyBasicAuth (fastify, opts) {
132132
if (err.statusCode === 401) {
133133
const header = authenticateHeader(req)
134134
if (header) {
135-
reply.header(...header)
135+
reply.header(header[0], header[1])
136136
}
137137
}
138138
next(err)
@@ -143,7 +143,7 @@ async function fastifyBasicAuth (fastify, opts) {
143143
}
144144
}
145145

146-
function getAuthenticateHeader (authenticate, useUtf8) {
146+
function getAuthenticateHeaders (authenticate, useUtf8) {
147147
const defaultHeaderName = 'WWW-Authenticate'
148148
if (!authenticate) return () => false
149149
if (authenticate === true) {

0 commit comments

Comments
 (0)