Fixing issue with double slash in websocket URL

This commit is contained in:
David Négrier 2021-03-31 17:50:27 +02:00
parent e166c69b58
commit adf2e60d54

View File

@ -69,7 +69,10 @@ export class RoomConnection implements RoomConnection {
public constructor(token: string|null, roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface) { public constructor(token: string|null, roomId: string, name: string, characterLayers: string[], position: PositionInterface, viewport: ViewportInterface) {
let url = new URL(PUSHER_URL, window.location.toString()).toString(); let url = new URL(PUSHER_URL, window.location.toString()).toString();
url = url.replace('http://', 'ws://').replace('https://', 'wss://'); url = url.replace('http://', 'ws://').replace('https://', 'wss://');
url += '/room'; if (!url.endsWith('/')) {
url += '/';
}
url += 'room';
url += '?roomId='+(roomId ?encodeURIComponent(roomId):''); url += '?roomId='+(roomId ?encodeURIComponent(roomId):'');
url += '&token='+(token ?encodeURIComponent(token):''); url += '&token='+(token ?encodeURIComponent(token):'');
url += '&name='+encodeURIComponent(name); url += '&name='+encodeURIComponent(name);