Simplify validating server URL

There is no need to send a HEAD request to the server since we now
bundle external_api.js.
This commit is contained in:
Saúl Ibarra Corretgé 2020-09-25 10:33:11 +02:00
parent 0bb919cffc
commit 730a6890be
9 changed files with 29 additions and 50 deletions

View file

@ -31,18 +31,6 @@ brew cask install jitsi-meet
### Using it with your own Jitsi Meet installation
In order to use this application with your own Jitsi Meet installation it's
necessary to enable the External API. Your server must serve a `external_api.js`
file at the root of the installation.
Here is an example using nginx:
```
location /external_api.js {
alias /usr/share/jitsi-meet/libs/external_api.min.js;
}
```
:warning: The following additional HTTP headers are known to break the Electron App:
```

View file

@ -9,7 +9,7 @@ import type { Dispatch } from 'redux';
import { compose } from 'redux';
import config from '../../config';
import { getExternalApiURL } from '../../utils';
import { normalizeServerURL } from '../../utils';
import { setServerURL } from '../actions';
import { Form } from '../styled';
@ -122,25 +122,32 @@ class ServerURLField extends Component<Props, State> {
}
/**
* Validates the Server URL by fetching external_api.js using the HEAD
* method.
* Validates the Server URL.
*
* @returns {void}
*/
_validateServerURL() {
fetch(getExternalApiURL(this.state.serverURL), {
method: 'HEAD'
})
.then((response: Object) => {
this.setState({
isValid: response.ok
});
})
.catch(() => {
this.setState({
isValid: false
});
});
if (!this.state.serverURL.trim()) {
return true;
}
const url = normalizeServerURL(this.state.serverURL);
let isValid;
try {
// eslint-disable-next-line no-new
const tmp = new URL(url);
if (!tmp.protocol.startsWith('http')) {
throw new Error('Invalid protocol');
}
isValid = true;
} catch (_) {
isValid = false;
}
this.setState({ isValid });
}
}

View file

@ -2,22 +2,6 @@
// @flow
import config from '../config';
/**
* Returns the URL of the external_api.js of the server.
*
* @param {string} serverURL - Jitsi Meet Server URL.
* @returns {string} - The external_api.js URL.
*/
export function getExternalApiURL(serverURL: string) {
if (!serverURL) {
// eslint-disable-next-line no-param-reassign
serverURL = config.defaultServerURL;
}
return `${normalizeServerURL(serverURL)}/external_api.js`;
}
/**
* Return true if Electron app is running on Mac system.

View file

@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Always on Top Window",
"startWithAudioMuted": "Start with Audio muted",
"startWithVideoMuted": "Start with Video muted",
"invalidServer": "Invalid Server URL or external API not enabled",
"invalidServer": "Invalid Server URL",
"invalidServerTimeout": "Invalid value for Server Timeout",
"serverUrl": "Server URL",
"serverTimeout": "Server Timeout (in seconds)"

View file

@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Ventana siempre encima",
"startWithAudioMuted": "Iniciar con audio desactivado",
"startWithVideoMuted": "Iniciar con video desactivado",
"invalidServer": "URL del servidor inválido o API externo no habilitada",
"invalidServer": "URL del servidor inválida",
"serverUrl": "URL del servidor",
"serverTimeout": "Tiempo de desconexión del servidor (en segundos)"
}

View file

@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Fenêtre Toujours au Dessus",
"startWithAudioMuted": "Démarrer avec le micro coupé",
"startWithVideoMuted": "Démarrer avec la caméra coupée",
"invalidServer": "URL invalide ou API externe non activée",
"invalidServer": "URL invalide",
"serverUrl": "URL du serveur",
"serverTimeout": "Délai de connexion au server (en secondes)"
}

View file

@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Mindig látható",
"startWithAudioMuted": "Elnémítva kezd",
"startWithVideoMuted": "Videó nélkül kezd",
"invalidServer": "Érvénytelen kiszolgáló URL-címe vagy külső API nincs engedélyezve",
"invalidServer": "Érvénytelen kiszolgáló URL-címe",
"invalidServerTimeout": "A kiszolgáló időkorlátja érvénytelen",
"serverUrl": "Kiszolgáló URL-címe",
"serverTimeout": "Kiszolgálói időkorlát (másodperc)"

View file

@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Finestra sempre in primo piano",
"startWithAudioMuted": "Inizia senza audio",
"startWithVideoMuted": "Inizio senza video",
"invalidServer": "URL del server errato o il server non supporta un'API esterna",
"invalidServer": "URL del server errato",
"serverUrl": "URL Server",
"serverTimeout": "Timeout del server (in secondi)"
}

View file

@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Поверх всех окон",
"startWithAudioMuted": "Начать без звука",
"startWithVideoMuted": "Начать без видео",
"invalidServer": "Неверный URL-адрес сервера или внешний API не включен",
"invalidServer": "Неверный URL-адрес сервера",
"serverUrl": "URL-адрес сервера",
"serverTimeout": "Тайм-аут сервера (в секундах)"
}