push
github
66 of 155 branches covered (42.58%)
Branch coverage included in aggregate %.
90 of 385 new or added lines in 14 files covered. (23.38%)
2 existing lines in 1 file now uncovered.213 of 3108 relevant lines covered (6.85%)
0.26 hits per line
|
NEW
|
export function getCookie(name) { |
|
|
NEW
|
const value = `; ${document.cookie}`; |
× |
|
NEW
|
const parts = value.split(`; ${name}=`); |
× |
|
NEW
|
if (parts.length === 2) return parts.pop().split(';').shift(); |
× |
|
NEW
|
} |
× |
| 6 |
|
|
|
NEW
|
export function getUserId() { |
× |
|
NEW
|
let userId = getCookie('userId');
|
× |
|
NEW
|
if (!userId) {
|
× |
|
NEW
|
userId = crypto.randomUUID(); |
× |
| 11 |
|
|
|
NEW
|
//! Set cookie for 1 year
|
× |
|
NEW
|
document.cookie = `userId=${userId}; path=/; max-age=${60 * 60 * 24 * 365}`; |
× |
|
NEW
|
} |
× |
|
NEW
|
return userId; |
× |
|
NEW
|
} |
× |