Skip to content

Commit

Permalink
fix: cookie parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan1951 committed Jan 31, 2025
1 parent 8733b26 commit 717ec06
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/entries/Background/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ export const onSendHeaders = (
details.requestHeaders.forEach((header) => {
const { name, value } = header;
if (/^cookie$/i.test(name) && value) {
value
.split(';')
.map((v) => v.split('='))
.forEach((cookie) => {
setCookies(link, cookie[0].trim(), cookie[1]);
});
value.split(';').forEach((cookieStr) => {
const index = cookieStr.indexOf('=');
if (index !== -1) {
const cookieName = cookieStr.slice(0, index).trim();
const cookieValue = cookieStr.slice(index + 1);
setCookies(link, cookieName, cookieValue);
}
});
} else {
setHeaders(link, name, value);
}
Expand Down

0 comments on commit 717ec06

Please sign in to comment.