diff --git a/assets/404.html b/assets/404.html index 0348ef4..b7511bf 100644 --- a/assets/404.html +++ b/assets/404.html @@ -34,12 +34,12 @@ const redirectConfig = [ // {regex: /^\/example$/, redirect: "/example.html"}, /* {regex: /\/.*\.xml$/, redirect: (path) => path.replace('.xml', '.html')} */ - {regex: /.*/, redirect: "/lean4/index.html"} + {regex: /.*/, redirect: "/lean4/index-non-exist.html"} ]; function redirectToPage() { - const referrer = document.referrer; - let path = referrer && referrer !== window.location.href && !referrer.includes('404.html') ? new URL(referrer).pathname : '/formal-land/'; + const referrer = document.referrer || window.location.href; + let path = referrer && !referrer.includes('404.html') ? new URL(referrer).pathname : '/formal-land/'; console.log('referrer:', path); const pathParts = path.split('/'); path = pathParts.length > 2 ? '/' + pathParts.slice(2).join('/') : path; @@ -50,10 +50,10 @@ if (rule.regex.test(path)) { const redirectTo = typeof rule.redirect === 'function' ? rule.redirect(path) : rule.redirect; if (redirectTo && !recentRedirects.includes(redirectTo)) { - if (recentRedirects.length >= 5) { + if (recentRedirects.length >= 3) { recentRedirects.shift(); } - recentRedirects.push(redirectTo); + recentRedirects.push(path); localStorage.setItem('recentRedirects', JSON.stringify(recentRedirects)); window.location.href = '/' + pathParts[1] + redirectTo; break;