Files
remark42/frontend/packages/api/lib/cookies.ts
T
2022-08-20 12:58:40 -05:00

12 lines
267 B
TypeScript

export function getCookie(name: string): string | undefined {
const matches = document.cookie.match(
new RegExp(`(?:^|; )${name.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1')}=([^;]*)`)
)
if (matches === null) {
return
}
return decodeURIComponent(matches[1])
}