diff --git a/tests/_registryServer.mjs b/tests/_registryServer.mjs index ff0be263f..d051b0a66 100644 --- a/tests/_registryServer.mjs +++ b/tests/_registryServer.mjs @@ -116,8 +116,10 @@ const server = createServer((req, res) => { const auth = req.headers.authorization; if ( - (auth?.startsWith(`Bearer `) && auth.slice(`Bearer `.length) !== TOKEN_MOCK) || - (auth?.startsWith(`Basic `) && Buffer.from(auth.slice(`Basic `.length), `base64`).toString() !== `user:pass`) + auth == null || + (auth.startsWith(`Bearer `) && auth.slice(`Bearer `.length) !== TOKEN_MOCK) || + (auth.startsWith(`Basic `) && Buffer.from(auth.slice(`Basic `.length), `base64`).toString() !== `user:pass`) || + !/^(Basic|Bearer) /.test(auth) ) { res.writeHead(401).end(`Unauthorized`); return;