TenantAtlas/apps/platform/.pnpm-store/v10/files/87/a00a55b3107a8d4ee40f82f90473980cf60fab253008f5899ca8d21067cd5a42e159c41f460038ed6a669aa595c7c506b67a50dbd1316c84fc6515748799ca
Ahmed Darrazi 9f74f7a658
Some checks failed
PR Fast Feedback / fast-feedback (pull_request) Failing after 51s
feat: compress governance operator outcomes
2026-04-19 14:15:11 +02:00

49 lines
1.4 KiB
Plaintext

import utils from '../utils.js';
import platform from '../platform/index.js';
export default platform.hasStandardBrowserEnv
? // Standard browser envs support document.cookie
{
write(name, value, expires, path, domain, secure, sameSite) {
if (typeof document === 'undefined') return;
const cookie = [`${name}=${encodeURIComponent(value)}`];
if (utils.isNumber(expires)) {
cookie.push(`expires=${new Date(expires).toUTCString()}`);
}
if (utils.isString(path)) {
cookie.push(`path=${path}`);
}
if (utils.isString(domain)) {
cookie.push(`domain=${domain}`);
}
if (secure === true) {
cookie.push('secure');
}
if (utils.isString(sameSite)) {
cookie.push(`SameSite=${sameSite}`);
}
document.cookie = cookie.join('; ');
},
read(name) {
if (typeof document === 'undefined') return null;
const match = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
return match ? decodeURIComponent(match[1]) : null;
},
remove(name) {
this.write(name, '', Date.now() - 86400000, '/');
},
}
: // Non-standard browser env (web workers, react-native) lack needed support.
{
write() {},
read() {
return null;
},
remove() {},
};