mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-05 07:49:58 +00:00
send cookies as-is
This commit is contained in:
parent
b2501cc98d
commit
ba7137ef62
2 changed files with 6 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue