Files
med-notes/.pnpm-store/v10/files/c8/46c5cf57c3b4a401a000a02037cd497852f11f0f5d0137115cc06b9bc009963b2bd65b538d9a244d6a4623c38ef0cdc2ad68e20abc29961b7fd5f047540493
2025-06-26 04:42:51 +00:00

43 lines
1.0 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) {
const cookie = [name + '=' + encodeURIComponent(value)];
utils.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
utils.isString(path) && cookie.push('path=' + path);
utils.isString(domain) && cookie.push('domain=' + domain);
secure === true && cookie.push('secure');
document.cookie = cookie.join('; ');
},
read(name) {
const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
return (match ? decodeURIComponent(match[3]) : 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() {}
};