Skip to content

Commit

Permalink
refactor(index): regex updates (#136)
Browse files Browse the repository at this point in the history
* refactor(index): use `i` case-insensitive flag over character ranges

* refactor(index): use word character inside regex character class
  • Loading branch information
Fdawgs committed Jul 19, 2024
1 parent 82beee6 commit c6ca15c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const MissingOrBadAuthorizationHeader = createError(
* The scheme name is "Basic".
* @see https://datatracker.ietf.org/doc/html/rfc7617#section-2
*/
const authScheme = '(?:[Bb][Aa][Ss][Ii][Cc])'
const authScheme = '(?:basic)'
/**
* The BWS rule is used where the grammar allows optional whitespace
* only for historical reasons. A sender MUST NOT generate BWS in
Expand All @@ -40,14 +40,14 @@ const BWS = '[ \t]'
* ([RFC4648]).
* @see https://datatracker.ietf.org/doc/html/rfc7235#section-2.1
*/
const token68 = '([A-Za-z0-9._~+/-]+=*)'
const token68 = '([\\w.~+/-]+=*)'

/**
* @see https://datatracker.ietf.org/doc/html/rfc7235#appendix-C
*/
const credentialsStrictRE = new RegExp(`^${authScheme} ${token68}$`)
const credentialsStrictRE = new RegExp(`^${authScheme} ${token68}$`, 'i')

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

/**
* @see https://datatracker.ietf.org/doc/html/rfc5234#appendix-B.1
Expand Down

0 comments on commit c6ca15c

Please sign in to comment.