From 38b6473fd44af1d9706314a2af87fcbf84c049fd Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Fri, 28 Nov 2025 10:34:17 +0000 Subject: [PATCH] refactor(index): enforce strict regex `u` unicode flag is equivalent to `'use strict'` directive in JS Signed-off-by: Frazer Smith --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 3fd3674..e4c60cf 100644 --- a/index.js +++ b/index.js @@ -41,15 +41,15 @@ const token68 = '([\\w.~+/-]+=*)' /** * @see https://datatracker.ietf.org/doc/html/rfc7235#appendix-C */ -const credentialsStrictRE = new RegExp(`^${authScheme} ${token68}$`, 'i') +const credentialsStrictRE = new RegExp(`^${authScheme} ${token68}$`, 'iu') -const credentialsLaxRE = new RegExp(`^${BWS}*${authScheme}${BWS}+${token68}${BWS}*$`, 'i') +const credentialsLaxRE = new RegExp(`^${BWS}*${authScheme}${BWS}+${token68}${BWS}*$`, 'iu') /** * @see https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1 */ // eslint-disable-next-line no-control-regex -const controlRE = /[\x00-\x1F\x7F]/ +const controlRE = /[\x00-\x1F\x7F]/u /** * RegExp for basic auth user/pass @@ -59,7 +59,7 @@ const controlRE = /[\x00-\x1F\x7F]/ * password = *TEXT */ -const userPassRE = /^([^:]*):(.*)$/ +const userPassRE = /^([^:]*):(.*)$/u /** @type {typeof import('./types/index').fastifyBasicAuth} */ async function fastifyBasicAuth (fastify, opts) {