Stop Firefox from adding mysterious hash (#3348)

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#"
```
This commit is contained in:
Patrick Bollinger 2023-10-08 21:58:43 -04:00 committed by GitHub
parent af276e4c39
commit e59167deaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);