From dcd43e98492b37babdf4b136fd81f410d3224d26 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 12 Jan 2022 19:08:55 -0500 Subject: [PATCH] webaccess: Use `.startsWith()` instead of `.search()` --- src/node/hooks/express/webaccess.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node/hooks/express/webaccess.js b/src/node/hooks/express/webaccess.js index 1e1adf41a..f9f368a4e 100644 --- a/src/node/hooks/express/webaccess.js +++ b/src/node/hooks/express/webaccess.js @@ -146,8 +146,7 @@ const checkAccess = async (req, res, next) => { const ctx = {req, res, users: settings.users, next}; // If the HTTP basic auth header is present, extract the username and password so it can be given // to authn plugins. - const httpBasicAuth = - req.headers.authorization && req.headers.authorization.search('Basic ') === 0; + const httpBasicAuth = req.headers.authorization && req.headers.authorization.startsWith('Basic '); if (httpBasicAuth) { const userpass = Buffer.from(req.headers.authorization.split(' ')[1], 'base64').toString().split(':');