Skip to content

Commit

Permalink
refactor(http/parser): improve cookie parsing regex for better whites…
Browse files Browse the repository at this point in the history
…pace handling
  • Loading branch information
Bluzzi committed Dec 22, 2024
1 parent 341fb4e commit 4c11afb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/http/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function parseCookies(cookies: string): Cookie[] {

return cookies
.split(";")
.filter(str => (/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+=[\x21\x23-\x2B\x2D\x2E\x30-\x39\x41-\x5A\x5E-\x7E]+$/).test(str))
.filter(str => (/^\s*([\w!#$%&'*+\-.^_`|~]+)\s*=\s*([^;]*)\s*$/).test(str) === true)
.map(cookie => {
const [rawName, rawValue] = cookie.split("=");

Expand Down

0 comments on commit 4c11afb

Please sign in to comment.