added an edge case for the default map url

This commit is contained in:
arp 2020-10-13 16:42:05 +02:00
parent d98efc0433
commit ccf80c1dd0
2 changed files with 9 additions and 1 deletions

View file

@ -7,6 +7,8 @@ import {localUserStore} from "./LocalUserStore";
import {LocalUser} from "./LocalUser";
import {Room} from "./Room";
const URL_ROOM_STARTED = '/Floor0/floor0.json';
class ConnectionManager {
private localUser!:LocalUser;
@ -53,7 +55,11 @@ class ConnectionManager {
return Promise.reject('Could not find a user in localstorage');
}
}
return Promise.reject('ConnexionManager initialization failed: invalid URL');
//todo: cleaner way to handle the default case
const defaultMapUrl = window.location.host.replace('api.', 'maps.') + URL_ROOM_STARTED;
const defaultRoomId = urlManager.editUrlForRoom(URL_ROOM_STARTED, null, null);
return Promise.resolve(new Room(defaultRoomId, defaultMapUrl));
}
public initBenchmark(): void {

View file

@ -36,6 +36,8 @@ class UrlManager {
}
//todo: simply use the roomId
//todo: test this with cypress
public editUrlForRoom(roomSlug: string, organizationSlug: string|null, worldSlug: string |null): string {
let newUrl:string;
if (organizationSlug) {