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 => {
|
str.split('; ').forEach(cookie => {
|
||||||
const key = cookie.split('=')[0];
|
const key = cookie.split('=')[0];
|
||||||
const value = cookie.split('=').splice(1).join('=');
|
const value = cookie.split('=').splice(1).join('=');
|
||||||
obj[key] = decodeURIComponent(value)
|
obj[key] = value
|
||||||
})
|
})
|
||||||
|
|
||||||
return new Cookie(obj)
|
return new Cookie(obj)
|
||||||
}
|
}
|
||||||
toString() {
|
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() {
|
toJSON() {
|
||||||
return this.toString()
|
return this.toString()
|
||||||
|
|
|
@ -49,8 +49,10 @@ export function getCookie(service) {
|
||||||
export function updateCookie(cookie, headers) {
|
export function updateCookie(cookie, headers) {
|
||||||
if (!cookie) return;
|
if (!cookie) return;
|
||||||
|
|
||||||
const parsed = parseSetCookie(splitCookiesString(headers.get('set-cookie'))),
|
const parsed = parseSetCookie(
|
||||||
values = {}
|
splitCookiesString(headers.get('set-cookie')),
|
||||||
|
{ decodeValues: false }
|
||||||
|
), values = {}
|
||||||
|
|
||||||
cookie.unset(parsed.filter(c => c.expires < new Date()).map(c => c.name));
|
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);
|
parsed.filter(c => c.expires > new Date()).forEach(c => values[c.name] = c.value);
|
||||||
|
|
Loading…
Reference in a new issue