Skip to content

Commit

Permalink
docs: mv comments about hyphen-literals to jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
trevor-anderson committed Jun 21, 2024
1 parent fb86390 commit 3898ccf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/sanitize/base64URL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { getSanitizerFn } from "./_helpers.js";
* - No line breaks are used
*
* @see https://base64.guru/standards/base64url
*
* **Pattern Notes:**
* - The hyphen literal is at the end of the group to avoid unintentional range creation.
*/
export const sanitizeBase64URL = getSanitizerFn(/[^a-zA-Z0-9_-]/g);
// Note: hyphen literal is at the end of the group to avoid range creation
4 changes: 3 additions & 1 deletion src/sanitize/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { getSanitizerFn } from "./_helpers.js";

/**
* Remove characters from `str` which are not valid in a JSON Web Token.
*
* **Pattern Notes:**
* - The hyphen literal is at the end of the group to avoid unintentional range creation.
*/
export const sanitizeJWT = getSanitizerFn(/[^a-zA-Z0-9._-]/g);
// Note: hyphen literal is at the end of the group to avoid range creation
4 changes: 3 additions & 1 deletion src/validate/base64URL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { getRegexValidatorFn } from "./_helpers.js";
* - Must be at least 2 characters long
*
* @see https://base64.guru/standards/base64url
*
* **Pattern Notes:**
* - The hyphen literal is at the end of the group to avoid unintentional range creation.
*/
export const isValidBase64URL = getRegexValidatorFn(/^[a-zA-Z0-9_-]{2,}$/);
// Note: hyphen literal is at the end of the group to avoid range creation
8 changes: 5 additions & 3 deletions src/validate/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { getRegexValidatorFn } from "./_helpers.js";
/**
* Returns `true` if `value` is a valid JWT.
*
* JWTs contain three [Base64URL-encoded][base64url] sections separated by periods (`.`).
* JWTs contain three [Base64URL-encoded](https://base64.guru/standards/base64url) sections
* separated by periods (`.`).
*
* [base64url]: https://base64.guru/standards/base64url
* **Pattern Notes:**
* - The minimum length is 2 characters per section.
* - Hyphen literals are at the end of their groups to avoid unintentional range creation.
*/
export const isValidJWT = getRegexValidatorFn(/^([a-zA-Z0-9_-]{2,}\.){2}[a-zA-Z0-9_-]{2,}$/);
// Note: hyphen literals are at the end of their groups to avoid range creation

0 comments on commit 3898ccf

Please sign in to comment.