Skip to content

Commit 38b6473

Browse files
authored
refactor(index): enforce strict regex
`u` unicode flag is equivalent to `'use strict'` directive in JS Signed-off-by: Frazer Smith <frazer.dev@icloud.com>
1 parent f18025a commit 38b6473

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ const token68 = '([\\w.~+/-]+=*)'
4141
/**
4242
* @see https://datatracker.ietf.org/doc/html/rfc7235#appendix-C
4343
*/
44-
const credentialsStrictRE = new RegExp(`^${authScheme} ${token68}$`, 'i')
44+
const credentialsStrictRE = new RegExp(`^${authScheme} ${token68}$`, 'iu')
4545

46-
const credentialsLaxRE = new RegExp(`^${BWS}*${authScheme}${BWS}+${token68}${BWS}*$`, 'i')
46+
const credentialsLaxRE = new RegExp(`^${BWS}*${authScheme}${BWS}+${token68}${BWS}*$`, 'iu')
4747

4848
/**
4949
* @see https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1
5050
*/
5151
// eslint-disable-next-line no-control-regex
52-
const controlRE = /[\x00-\x1F\x7F]/
52+
const controlRE = /[\x00-\x1F\x7F]/u
5353

5454
/**
5555
* RegExp for basic auth user/pass
@@ -59,7 +59,7 @@ const controlRE = /[\x00-\x1F\x7F]/
5959
* password = *TEXT
6060
*/
6161

62-
const userPassRE = /^([^:]*):(.*)$/
62+
const userPassRE = /^([^:]*):(.*)$/u
6363

6464
/** @type {typeof import('./types/index').fastifyBasicAuth} */
6565
async function fastifyBasicAuth (fastify, opts) {

0 commit comments

Comments
 (0)