fix: When adding a room param to urls check for previous params.

This commit is contained in:
Дамян Минков 2022-05-31 16:05:43 -05:00
parent de294cae92
commit 28ef20589b
4 changed files with 22 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import {
JitsiConnectionEvents
} from './react/features/base/lib-jitsi-meet';
import { isFatalJitsiConnectionError } from './react/features/base/lib-jitsi-meet/functions';
import { appendURLParam } from './react/features/base/util';
import { getCustomerDetails } from './react/features/jaas/actions.any';
import { isVpaasMeeting, getJaasJWT } from './react/features/jaas/functions';
import { setPrejoinDisplayNameRequired } from './react/features/prejoin/actions';
@ -102,14 +103,11 @@ export async function connect(id, password, roomName) {
// Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
// that this code executes only on web browsers/electron. This needs to be changed when mobile and web are unified.
let serviceUrl = connectionConfig.websocket || connectionConfig.bosh;
serviceUrl += `?room=${roomName}`;
connectionConfig.serviceUrl = serviceUrl;
connectionConfig.serviceUrl = appendURLParam(connectionConfig.websocket || connectionConfig.bosh, 'room', roomName);
if (connectionConfig.websocketKeepAliveUrl) {
connectionConfig.websocketKeepAliveUrl += `?room=${roomName}`;
connectionConfig.websocketKeepAliveUrl
= appendURLParam(connectionConfig.websocketKeepAliveUrl, 'room', roomName);
}
const connection = new JitsiMeetJS.JitsiConnection(null, jwt, connectionConfig);

View File

@ -7,6 +7,7 @@ import { conferenceLeft, conferenceWillLeave } from '../conference/actions';
import { getCurrentConference } from '../conference/functions';
import JitsiMeetJS, { JitsiConnectionEvents } from '../lib-jitsi-meet';
import {
appendURLParam,
getBackendSafeRoomName,
parseURIString
} from '../util';
@ -315,10 +316,10 @@ function _constructOptions(state) {
if (serviceUrl && room) {
const roomName = getBackendSafeRoomName(room);
options.serviceUrl = `${serviceUrl}?room=${roomName}`;
options.serviceUrl = appendURLParam(serviceUrl, 'room', roomName);
if (options.websocketKeepAliveUrl) {
options.websocketKeepAliveUrl += `?room=${roomName}`;
options.websocketKeepAliveUrl = appendURLParam(options.websocketKeepAliveUrl, 'room', roomName);
}
}

View File

@ -603,3 +603,16 @@ export function addHashParamsToURL(url: URL, hashParamsToAdd: Object = {}) {
export function getDecodedURI(uri: string) {
return decodeURI(uri.replace(/^https?:\/\//i, ''));
}
/**
* Adds new param to a url string. Checks whether to use '?' or '&' as a separator (checks for already existing params).
*
* @param {string} url - The url to modify.
* @param {string} name - The param name to add.
* @param {string} value - The value for the param.
*
* @returns {string} - The modified url.
*/
export function appendURLParam(url: string, name: string, value: string) {
return `${url}${url.includes('?') ? '&' : '?'}${name}=${value}`;
}

View File

@ -8,7 +8,7 @@ import { i18next } from '../base/i18n';
import { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
import { getLocalParticipant, isLocalParticipantModerator } from '../base/participants';
import { toState } from '../base/redux';
import { parseURIString } from '../base/util';
import { appendURLParam, parseURIString } from '../base/util';
import { isVpaasMeeting } from '../jaas/functions';
import { getDialInConferenceID, getDialInNumbers } from './_utils';
@ -596,7 +596,7 @@ export function getDialInfoPageURL(state: Object, roomName: ?string) {
const url = didPageUrl || `${href.substring(0, href.lastIndexOf('/'))}/${DIAL_IN_INFO_PAGE_PATH_NAME}`;
return `${url}?room=${room}`;
return appendURLParam(url, 'room', room);
}
/**