Use the current hostname in schemeSwap.js instead of hard coding it

This commit is contained in:
floppydiskette 2024-07-12 22:43:15 +01:00
parent d0fb028c3e
commit 6f695daddc
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE

View file

@ -26,10 +26,11 @@ function getCookie(cname) {
* @param {number} exdays Cookie lifespan (days) * @param {number} exdays Cookie lifespan (days)
*/ */
function setCookie(cname, cvalue, exdays) { function setCookie(cname, cvalue, exdays) {
const hostname = window.location.hostname;
const d = new Date(); const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000)); d.setTime(d.getTime() + (exdays*24*60*60*1000));
let expires = "expires="+ d.toUTCString(); let expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/;SameSite=Strict;Domain=.diskfloppy.me"; document.cookie = `${cname}=${cvalue};${expires};path=/;SameSite=Strict;Domain=${hostname}`
} }
/** /**