Skip to content

Commit eb8ca82

Browse files
committed
Scope the cookie to the domain
1 parent 0bc27ab commit eb8ca82

File tree

2 files changed

+1
-13
lines changed

2 files changed

+1
-13
lines changed

src/lib/darkMode.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,13 @@ export function startObservingColorSchemeHtmlAttribute() {
7272

7373
{
7474
const setColorSchemeCookie = (colorScheme: ColorScheme) => {
75-
console.log("DEBUG: setColorSchemeCookie");
76-
7775
let newCookie = `${data_fr_theme}=${colorScheme};path=/;max-age=31536000`;
7876

7977
//We do not set the domain if we are on localhost or an ip
8078
if (window.location.hostname.match(/\.[a-zA-Z]{2,}$/)) {
81-
console.log("DEBUG: Append to newCookie");
82-
83-
newCookie += `;domain=${
84-
window.location.hostname.split(".").length >= 3
85-
? window.location.hostname.replace(/^[^.]+\./, "")
86-
: window.location.hostname
87-
}`;
79+
newCookie += `;domain=${window.location.hostname}`;
8880
}
8981

90-
console.log(`DEBUG: set newCookie: ${newCookie}`);
91-
9282
document.cookie = newCookie;
9383
};
9484

src/lib/start.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ export async function startDsfrReact(params: Params) {
6767
);
6868
}
6969

70-
console.log("DEBUG: startObservingColorSchemeHtmlAttribute");
71-
7270
startObservingColorSchemeHtmlAttribute();
7371

7472
(window as any).dsfr = { verbose, "mode": "manual" };

0 commit comments

Comments
 (0)