From e59167deaa3a74a98c3586e3cfd293f5d1cd092d Mon Sep 17 00:00:00 2001 From: Patrick Bollinger Date: Sun, 8 Oct 2023 21:58:43 -0400 Subject: [PATCH] Stop Firefox from adding mysterious hash (#3348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This resolves https://github.com/owncast/owncast/issues/3240 From the comments: This was trickier than expected, but the root of the problem is Firefox will set `#` in the URL bar when `window.location.hash` is set to _any_ string, even a blank string. The morale of the story is, don't mutate base data if you just want to copy values. 😅 Sample of Firefox JavaScript console session that demonstrates the issue: ```javascript >> window.location.href "https://github.com/owncast/owncast/issues/3240" >> const setBlankHash = () => { window.location.hash = ''; }; undefined >> window.location.hash "" >> window.location.href "https://github.com/owncast/owncast/issues/3240" >> setBlankHash() undefined >> // My browser just jumped to the top of the page undefined >> window.location.hash "" >> window.location.href "https://github.com/owncast/owncast/issues/3240#" ``` --- web/components/stores/ClientConfigStore.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web/components/stores/ClientConfigStore.tsx b/web/components/stores/ClientConfigStore.tsx index 37850c5bb..912e30287 100644 --- a/web/components/stores/ClientConfigStore.tsx +++ b/web/components/stores/ClientConfigStore.tsx @@ -374,9 +374,7 @@ export const ClientConfigStore: FC = () => { const { socketHostOverride } = clientConfig; // Get a copy of the browser location without #fragments. - const l = window.location; - l.hash = ''; - const location = l.toString().replaceAll('#', ''); + const location = window.location.origin + window.location.pathname; const host = socketHostOverride || location; ws = new WebsocketService(accessToken, '/ws', host);