| 33 | } |
| 34 | |
| 35 | public static get(id: string) { |
| 36 | if (!id.length) { |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | if (!CookieStorage.enabled()) { |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | id = id.toLowerCase(); |
| 45 | |
| 46 | const cookies = document.cookie.split(';').map(cookie => { |
| 47 | const fragments = cookie.split('='); |
| 48 | |
| 49 | return { |
| 50 | id: fragments[0].trim(), |
| 51 | value: fragments[1] |
| 52 | }; |
| 53 | }); |
| 54 | |
| 55 | return ( |
| 56 | cookies.find(cookie => id === cookie.id.toLocaleLowerCase()) || |
| 57 | ({} as any) |
| 58 | ).value; |
| 59 | } |
| 60 | |
| 61 | public static set(id: string, value: string, domain = '', path = '/') { |
| 62 | if (!CookieStorage.enabled()) { |