]> git.ardis.lu - ardislu.dev/commitdiff
Move feed redirect to route()
authorArdis Lu <ardisglu@gmail.com>
Fri, 5 Aug 2022 04:33:02 +0000 (21:33 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 5 Aug 2022 04:33:02 +0000 (21:33 -0700)
Otherwise back button will not work as expected

script.js

index 85b95b0df6269df050c8a29733047d560d960c55..4fdcee0c350aac2328787b3b08121bd6bc1489ad 100644 (file)
--- a/script.js
+++ b/script.js
@@ -163,9 +163,6 @@ async function showPage(path) {
     document.querySelector('main').replaceWith(postMain);
     hljs.highlightAll();
   }
-  else if (path === '/atom.xml') {
-    location.href = `${location.origin}${path}`;
-  }
   else {
     // MUST redirect to a page where the web server serves an actual 404 error (i.e. not just 
     // index.html again) otherwise this triggers an infinite loop
@@ -181,8 +178,8 @@ function route(href) {
   if (location.href === url.href) {
     return;
   }
-  // If the new page is on a different host, redirect as expected
-  if (location.host !== url.host) {
+  // Redirect as expected for outside hosts or Atom feed
+  else if (location.host !== url.host || href === 'https://ardislu.dev/atom.xml') {
     location.href = href;
     return;
   }
This page took 0.050692 seconds and 4 git commands to generate.