From d7d4612b2df2b4f87dfe64aafdcda8b8e8142c18 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 12 Feb 2020 09:36:46 +0000 Subject: [PATCH] FIX: Subfolder sites rewriting URLs to root domain on initial load (#8932) The `DiscourseLocation.initState` function was accidently renamed in 0431942f (select-kit-2) to `initOptions`. This means that the ember router does not automatically call the function after the router is initialized. For a long time, we have been calling the `initState` function in the `init` function of discourse-location, which caused an imperceptible URL change to the the root domain, before switching back to the correct subfolder URL when ember called `initState`. This commit removes that call from the initializer, so `initState` is only called once (by ember). Relevant ember code: https://github.com/emberjs/ember.js/blob/v3.12.2/packages/@ember/-internals/routing/lib/system/router.ts#L695-L699 --- .../javascripts/discourse/lib/discourse-location.js.es6 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/discourse-location.js.es6 b/app/assets/javascripts/discourse/lib/discourse-location.js.es6 index 8c10f353a8..ba03ee5017 100644 --- a/app/assets/javascripts/discourse/lib/discourse-location.js.es6 +++ b/app/assets/javascripts/discourse/lib/discourse-location.js.es6 @@ -18,7 +18,6 @@ const DiscourseLocation = EmberObject.extend({ this._super(...arguments); this.set("location", this.location || window.location); - this.initOptions(); }, /** @@ -26,9 +25,9 @@ const DiscourseLocation = EmberObject.extend({ Used to set state on first call to setURL - @method initOptions + @method initState */ - initOptions() { + initState() { const history = this.history || window.history; if (history && history.scrollRestoration) { history.scrollRestoration = "manual";