new https cookie behavior

This commit is contained in:
Steven Hugg 2019-05-21 15:41:17 -04:00
parent 98423c7fa2
commit 0ea0ac2f60
2 changed files with 11 additions and 13 deletions

View File

@ -383,8 +383,8 @@ if (window.location.host.endsWith('8bitworkshop.com')) {
<option value="private">Private</option>
</select></p>
<p>License: <select id="githubRepoLicense">
<option value="">Will decide later</option>
<option value="cc0-1.0">CC Zero (public domain, recommended)</option>
<option value="">Will decide later / all rights reserved</option>
<option value="cc0-1.0">CC Zero (public domain, remix-friendly)</option>
<option value="mit">MIT (must preserve notices)</option>
<option value="cc-by-4.0">CC BY (must attribute)</option>
<option value="cc-by-sa-4.0">CC BY-SA (must attribute, use same license)</option>

View File

@ -1862,18 +1862,16 @@ function convertLegacyVCS(store) {
const useHTTPSCookieName = "__use_https";
function shouldRedirectHTTPS() {
// cookie set?
if (getCookie(useHTTPSCookieName)) {
return true;
function shouldRedirectHTTPS() : boolean {
// cookie set? either true or false
var shouldRedir = getCookie(useHTTPSCookieName);
if (typeof shouldRedir === 'string') {
return !!shouldRedir; // convert to bool
}
// is this our first time here? if so, set a 10yr cookie
if (hasLocalStorage && !localStorage.getItem("__lastplatform")) {
document.cookie = useHTTPSCookieName + "=1;domain=8bitworkshop.com;path=/;max-age=315360000";
return true;
}
// we can't redirect, might still have HTTP files
return false;
// set a 10yr cookie, value depends on if it's our first time here
var val = hasLocalStorage && !localStorage.getItem("__lastplatform") ? 1 : 0;
document.cookie = useHTTPSCookieName + "=" + val + ";domain=8bitworkshop.com;path=/;max-age=315360000";
return !!val;
}
function redirectToHTTPS() {