FIX: Don't push browser state if navigated from root url to home page url and vice versa

FIX: Don’t push browser state if navigated from root url to home page url and vice versa

diff --git a/app/assets/javascripts/discourse/lib/discourse-location.js.es6 b/app/assets/javascripts/discourse/lib/discourse-location.js.es6
index 576b135..f2585af 100644
--- a/app/assets/javascripts/discourse/lib/discourse-location.js.es6
+++ b/app/assets/javascripts/discourse/lib/discourse-location.js.es6
@@ -1,3 +1,5 @@
+import { defaultHomepage } from "discourse/lib/utilities";
+
 /**
 @module Discourse
 */
@@ -87,7 +89,10 @@ const DiscourseLocation = Ember.Object.extend({
     path = this.formatURL(path);
 
     if (state && state.path !== path) {
-      this.pushState(path);
+      const paths = [path, state.path];
+      if (!(paths.includes("/") && paths.includes(`/${defaultHomepage()}`))) {
+        this.pushState(path);
+      }
     }
   },

GitHub sha: 0861ca77

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

1 Like