Skip to content

Commit

Permalink
perf(parse): optimize regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
TomokiMiyauci committed May 2, 2023
1 parent e3adef4 commit b86dcd6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ type AuthParam = [key: string, value: Token | QuotedString];

/** Generate from _abnf.ts. */
const reAuthParam =
/^(?<key>[\w!#$%&'*+.^`|~-]+?)[\t ]*?=[\t ]*?(?:(?<token>[\w!#$%&'*+.^`|~-]+?)|(?<quotedString>"(?:\t| |!|[ \x23-\x5B\x5D-\x7E]|[\x80-\xFF]|\\(?:\t| |[\x21-\x7E]|[\x80-\xFF]))*?"))$/;
/^(?<key>[\w!#$%&'*+.^`|~-]+?)[\t ]*?=[\t ]*?(?:(?<token>[\w!#$%&'*+.^`|~-]+?)|(?<quotedString>"(?:[\t !\x23-\x5B\x5D-\x7E\x80-\xFF]|\\[\t \x21-\x7E\x80-\xFF])*?"))$/;

/** Parse string into {@link AuthParam}.
* @throws {SyntaxError} It the input is invalid [auth-param](https://www.rfc-editor.org/rfc/rfc9110.html#section-11.2-5).
Expand Down

0 comments on commit b86dcd6

Please sign in to comment.