fix(cookie): parsing of header not working with percentage char (#2989)
This commit is contained in:
@@ -1,22 +1,8 @@
|
||||
import type { CookieSerializeOptions } from "cookie";
|
||||
import { serialize } from "cookie";
|
||||
import { parse, serialize } from "cookie";
|
||||
|
||||
export function parseCookies(cookieString: string) {
|
||||
const list: Record<string, string> = {};
|
||||
const cookieHeader = cookieString;
|
||||
if (!cookieHeader) return list;
|
||||
|
||||
cookieHeader.split(";").forEach(function (cookie) {
|
||||
const items = cookie.split("=");
|
||||
let name = items.shift();
|
||||
name = name?.trim();
|
||||
if (!name) return;
|
||||
const value = items.join("=").trim();
|
||||
if (!value) return;
|
||||
list[name] = decodeURIComponent(value);
|
||||
});
|
||||
|
||||
return list;
|
||||
return parse(cookieString);
|
||||
}
|
||||
|
||||
export function setClientCookie(name: string, value: string, options: CookieSerializeOptions = {}) {
|
||||
|
||||
Reference in New Issue
Block a user