This repository has been archived on 2024-06-14. You can view files and clone it, but cannot push or open issues or pull requests.
icynet-admin/lib/utils/get-cookie.ts

15 lines
298 B
TypeScript
Raw Normal View History

2022-08-29 18:09:28 +00:00
export function getCookie(
cname: string,
cookie: string | undefined
): string | undefined {
if (!cookie) {
return undefined;
}
const name = cname + '=';
return decodeURIComponent(cookie)
.split(';')
.find((entry) => entry.startsWith(name))
?.substring(name.length);
}