blah
This commit is contained in:
parent
a8a8701739
commit
1b75e89ca4
7
dist/cookieManager.js
vendored
7
dist/cookieManager.js
vendored
@ -7,11 +7,14 @@ export default class CookieManager {
|
|||||||
headers?.forEach(header => {
|
headers?.forEach(header => {
|
||||||
const [cookiePart, ...attributes] = header.split(';').map(part => part.trim());
|
const [cookiePart, ...attributes] = header.split(';').map(part => part.trim());
|
||||||
const [name, value] = cookiePart.split('=');
|
const [name, value] = cookiePart.split('=');
|
||||||
const cookie = { value: value || "", domain };
|
const cookie = { value: value || "" };
|
||||||
attributes.forEach(attr => {
|
attributes.forEach(attr => {
|
||||||
const [key, val] = attr.split('=');
|
const [key, val] = attr.split('=');
|
||||||
const lowerKey = key.toLowerCase();
|
const lowerKey = key.toLowerCase();
|
||||||
switch (lowerKey) {
|
switch (lowerKey) {
|
||||||
|
case 'domain':
|
||||||
|
cookie.domain = val;
|
||||||
|
break;
|
||||||
case 'path':
|
case 'path':
|
||||||
cookie.path = val;
|
cookie.path = val;
|
||||||
break;
|
break;
|
||||||
@ -38,7 +41,7 @@ export default class CookieManager {
|
|||||||
format(domain) {
|
format(domain) {
|
||||||
this.cleanupExpiredCookies();
|
this.cleanupExpiredCookies();
|
||||||
return Object.entries(this.cookies[domain] || {})
|
return Object.entries(this.cookies[domain] || {})
|
||||||
.map(([key, value]) => `${key}=${value.value}`)
|
.map(([key, value]) => `${key}=${value.value.toString()}`)
|
||||||
.join('; ');
|
.join('; ');
|
||||||
}
|
}
|
||||||
getCookies(domain) {
|
getCookies(domain) {
|
||||||
|
@ -30,11 +30,12 @@ export default class CookieManager {
|
|||||||
const [cookiePart, ...attributes] = header.split(';').map(part => part.trim());
|
const [cookiePart, ...attributes] = header.split(';').map(part => part.trim());
|
||||||
const [name, value] = cookiePart.split('=');
|
const [name, value] = cookiePart.split('=');
|
||||||
|
|
||||||
const cookie: Cookie = { value: value || "", domain };
|
const cookie: Cookie = { value: value || "" };
|
||||||
attributes.forEach(attr => {
|
attributes.forEach(attr => {
|
||||||
const [key, val] = attr.split('=');
|
const [key, val] = attr.split('=');
|
||||||
const lowerKey = key.toLowerCase();
|
const lowerKey = key.toLowerCase();
|
||||||
switch(lowerKey) {
|
switch(lowerKey) {
|
||||||
|
case 'domain': cookie.domain = val; break;
|
||||||
case 'path': cookie.path = val; break;
|
case 'path': cookie.path = val; break;
|
||||||
case 'expires': cookie.expires = val ? new Date(val) : undefined; break;
|
case 'expires': cookie.expires = val ? new Date(val) : undefined; break;
|
||||||
case 'max-age': cookie.maxAge = parseInt(val, 10); break;
|
case 'max-age': cookie.maxAge = parseInt(val, 10); break;
|
||||||
@ -51,7 +52,7 @@ export default class CookieManager {
|
|||||||
format(domain: string): string {
|
format(domain: string): string {
|
||||||
this.cleanupExpiredCookies();
|
this.cleanupExpiredCookies();
|
||||||
return Object.entries(this.cookies[domain] || {})
|
return Object.entries(this.cookies[domain] || {})
|
||||||
.map(([key, value]) => `${key}=${value.value}`)
|
.map(([key, value]) => `${key}=${value.value.toString()}`)
|
||||||
.join('; ');
|
.join('; ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user