diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-03 10:47:58 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-03 10:47:58 +0200 |
| commit | a4e19d393a10f3ec075ee114a51b6204f26089b1 (patch) | |
| tree | 1f3a93e7ad15b3520c8a801cae88a2af3337fcd1 /apps/kit/src | |
| parent | e8f5a66e5e607279eb810266bf5d907a8ef78e57 (diff) | |
| download | greatoffice-a4e19d393a10f3ec075ee114a51b6204f26089b1.tar.xz greatoffice-a4e19d393a10f3ec075ee114a51b6204f26089b1.zip | |
refactor: Use location.hostname as default domain
Diffstat (limited to 'apps/kit/src')
| -rw-r--r-- | apps/kit/src/lib/helpers.ts | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/apps/kit/src/lib/helpers.ts b/apps/kit/src/lib/helpers.ts index c4e2e51..6f52dc6 100644 --- a/apps/kit/src/lib/helpers.ts +++ b/apps/kit/src/lib/helpers.ts @@ -35,23 +35,13 @@ export function is_norwegian_phone_number(value: string): boolean { return NORWEGIAN_PHONE_NUMBER_REGEX.test(String(value)); } -// export function switch_theme() { -// const html = document.querySelector("html"); -// if (html.dataset.theme === "dark") { -// html.dataset.theme = "light"; -// } else { -// html.dataset.theme = "dark"; -// } -// set_cookie(CookieNames.theme, html.dataset.theme, base_domain()); -// } - export function get_cookie(name: string) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop()?.split(";").shift(); } -export function set_cookie(name: string, value: string, baseDomain = window.location.host) { +export function set_cookie(name: string, value: string, baseDomain = window.location.hostname) { document.cookie = name + "=" + encodeURIComponent(value) + (baseDomain ? ";domain=" + baseDomain : ""); } |
