Update url when its contains an unknown server

This commit is contained in:
James Lyne 2021-05-18 16:49:22 +01:00
parent 1173dcbbce
commit 58009adfef

View File

@ -93,6 +93,11 @@ API.validateConfiguration().then((config) => {
const lastSegment = window.location.pathname.split('/').pop(), const lastSegment = window.location.pathname.split('/').pop(),
serverName = lastSegment && config.has(lastSegment) ? lastSegment : config.keys().next().value; serverName = lastSegment && config.has(lastSegment) ? lastSegment : config.keys().next().value;
//Update url if server doesn't exist
if(serverName !== lastSegment) {
window.history.replaceState({}, '', store.state.servers.get(serverName)!.url + window.location.hash);
}
store.commit(MutationTypes.SET_CURRENT_SERVER, serverName); store.commit(MutationTypes.SET_CURRENT_SERVER, serverName);
} else { } else {
store.commit(MutationTypes.SET_CURRENT_SERVER, config.keys().next().value); store.commit(MutationTypes.SET_CURRENT_SERVER, config.keys().next().value);