get-apex-domain
Version:
Returns the apex domain (aka base, bare, naked, root apex, or zone apex domain) of the current web page without the use of a public suffix list. The apex domain is also the top-most domain that allows for setting cookies.
19 lines (15 loc) • 341 B
JavaScript
const get = name => {
var v = document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
return v ? v[2] : null;
};
const set = (name, value, domain) => {
document.cookie = `${name}=${value};domain=${domain}`;
};
const remove = (name, domain) => {
set(name, "", domain, new Date(0));
};
export default {
get,
set,
remove
};