send cookies as-is

This commit is contained in:
dumbmoron 2023-08-20 22:18:32 +00:00
parent b2501cc98d
commit ba7137ef62
2 changed files with 6 additions and 4 deletions

View file

@ -20,13 +20,13 @@ export default class Cookie {
str.split('; ').forEach(cookie => {
const key = cookie.split('=')[0];
const value = cookie.split('=').splice(1).join('=');
obj[key] = decodeURIComponent(value)
obj[key] = value
})
return new Cookie(obj)
}
toString() {
return Object.entries(this._values).map(([ name, value ]) => `${name}=${encodeURIComponent(value)}`).join('; ')
return Object.entries(this._values).map(([ name, value ]) => `${name}=${value}`).join('; ')
}
toJSON() {
return this.toString()

View file

@ -49,8 +49,10 @@ export function getCookie(service) {
export function updateCookie(cookie, headers) {
if (!cookie) return;
const parsed = parseSetCookie(splitCookiesString(headers.get('set-cookie'))),
values = {}
const parsed = parseSetCookie(
splitCookiesString(headers.get('set-cookie')),
{ decodeValues: false }
), values = {}
cookie.unset(parsed.filter(c => c.expires < new Date()).map(c => c.name));
parsed.filter(c => c.expires > new Date()).forEach(c => values[c.name] = c.value);