]> git.ardis.lu - minimal-routing/commitdiff
Simplify window.location references
authorArdis Lu <ardisglu@gmail.com>
Fri, 30 Sep 2022 05:20:57 +0000 (22:20 -0700)
committerArdis Lu <ardisglu@gmail.com>
Fri, 30 Sep 2022 05:20:57 +0000 (22:20 -0700)
index.html

index 7d733acaf0428187cf66915c723cd8c541208a0d..cf56544c1f86e309813166f6b69f2c78a5b9ba3d 100644 (file)
       if (!match) {
         // 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
-        window.location.href = `${window.location.protocol}//${window.location.host}/errors/NotFound`;
+        window.location.href = `${window.location.origin}/errors/NotFound`;
       }
     }
 
         return;
       }
 
-      const base = new URL(`${window.location.protocol}//${window.location.host}`);
+      const base = new URL(`${window.location.origin}`);
       const url = new URL(path, base);
       window.history.pushState({}, '', url);
 
This page took 0.044373 seconds and 4 git commands to generate.