12 lines
267 B
TypeScript
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])
|
|
}
|