fix: Always normalizes bosh config.

This commit is contained in:
damencho 2023-01-13 14:07:20 -06:00 committed by Дамян Минков
parent d0fe034db5
commit 1466d7d149
3 changed files with 25 additions and 24 deletions

View File

@ -46,7 +46,7 @@ var config = {
},
// BOSH URL. FIXME: use XEP-0156 to discover it.
bosh: '//jitsi-meet.example.com/' + subdir + 'http-bind',
bosh: 'https://jitsi-meet.example.com/' + subdir + 'http-bind',
// Websocket URL
// websocket: 'wss://jitsi-meet.example.com/' + subdir + 'xmpp-websocket',

View File

@ -98,7 +98,7 @@ export function overwriteConfig(config: Object) {
* base/config.
* @returns {Function}
*/
export function setConfig(config: Object = {}) {
export function setConfig(config: IConfig = {}) {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
const { locationURL } = getState()['features/base/connection'];
@ -119,6 +119,26 @@ export function setConfig(config: Object = {}) {
window.interfaceConfig,
locationURL);
let { bosh } = config;
if (bosh) {
// Normalize the BOSH URL.
if (bosh.startsWith('//')) {
// By default our config.js doesn't include the protocol.
bosh = `${locationURL?.protocol}${bosh}`;
} else if (bosh.startsWith('/')) {
// Handle relative URLs, which won't work on mobile.
const {
protocol,
host,
contextRoot
} = parseURIString(locationURL?.href);
bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
}
config.bosh = bosh;
}
dispatch({
type: SET_CONFIG,
config

View File

@ -3,8 +3,7 @@ import _ from 'lodash';
import { IReduxState } from '../../app/types';
import {
appendURLParam,
getBackendSafeRoomName,
parseURIString
getBackendSafeRoomName
} from '../util/uri';
import {
@ -145,7 +144,8 @@ export function constructOptions(state: IReduxState) {
// redux store.
const options = _.cloneDeep(state['features/base/config']);
let { bosh, websocket } = options;
const { bosh } = options;
let { websocket } = options;
// TESTING: Only enable WebSocket for some percentage of users.
if (websocket && navigator.product === 'ReactNative') {
@ -154,25 +154,6 @@ export function constructOptions(state: IReduxState) {
}
}
// Normalize the BOSH URL.
if (bosh && !websocket) {
const { locationURL } = state['features/base/connection'];
if (bosh.startsWith('//')) {
// By default our config.js doesn't include the protocol.
bosh = `${locationURL?.protocol}${bosh}`;
} else if (bosh.startsWith('/')) {
// Handle relative URLs, which won't work on mobile.
const {
protocol,
host,
contextRoot
} = parseURIString(locationURL?.href);
bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
}
}
// WebSocket is preferred over BOSH.
const serviceUrl = websocket || bosh;