mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
http/cookie: fixing equal character split (denoland/deno_std#368)
Original: 8503efc8f7
This commit is contained in:
parent
ce101a0f86
commit
a814cfc3e1
2 changed files with 9 additions and 1 deletions
|
@ -79,7 +79,7 @@ export function getCookies(req: ServerRequest): Cookies {
|
||||||
for (const kv of c) {
|
for (const kv of c) {
|
||||||
const cookieVal = kv.split("=");
|
const cookieVal = kv.split("=");
|
||||||
const key = cookieVal.shift().trim();
|
const key = cookieVal.shift().trim();
|
||||||
out[key] = cookieVal.join("");
|
out[key] = cookieVal.join("=");
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,14 @@ test({
|
||||||
req.headers = new Headers();
|
req.headers = new Headers();
|
||||||
req.headers.set("Cookie", "igot=99; problems=but...");
|
req.headers.set("Cookie", "igot=99; problems=but...");
|
||||||
assertEquals(getCookies(req), { igot: "99", problems: "but..." });
|
assertEquals(getCookies(req), { igot: "99", problems: "but..." });
|
||||||
|
|
||||||
|
req.headers = new Headers();
|
||||||
|
req.headers.set("Cookie", "PREF=al=en-GB&f1=123; wide=1; SID=123");
|
||||||
|
assertEquals(getCookies(req), {
|
||||||
|
PREF: "al=en-GB&f1=123",
|
||||||
|
wide: "1",
|
||||||
|
SID: "123"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue