aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2020-09-25 10:33:11 +0200
committerSaúl Ibarra Corretgé <s@saghul.net>2020-09-25 10:33:11 +0200
commit730a6890bee02e2c5b90f9e19f896b6c05d4461c (patch)
tree0f65e233fa8b94f204db23109632f47deae52806
parent0bb919cffc2c8ad41564226d5b3ae30acf866201 (diff)
Simplify validating server URL
There is no need to send a HEAD request to the server since we now bundle external_api.js.
-rw-r--r--README.md12
-rw-r--r--app/features/settings/components/ServerURLField.js39
-rw-r--r--app/features/utils/functions.js16
-rw-r--r--app/i18n/lang/en.json2
-rw-r--r--app/i18n/lang/es.json2
-rw-r--r--app/i18n/lang/fr.json2
-rw-r--r--app/i18n/lang/hu.json2
-rw-r--r--app/i18n/lang/it.json2
-rw-r--r--app/i18n/lang/ru.json2
9 files changed, 29 insertions, 50 deletions
diff --git a/README.md b/README.md
index ad8c2a2..6ab5223 100644
--- a/README.md
+++ b/README.md
@@ -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:
```
diff --git a/app/features/settings/components/ServerURLField.js b/app/features/settings/components/ServerURLField.js
index 09ae945..b069eba 100644
--- a/app/features/settings/components/ServerURLField.js
+++ b/app/features/settings/components/ServerURLField.js
@@ -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 });
}
}
diff --git a/app/features/utils/functions.js b/app/features/utils/functions.js
index e8e11e2..36db8b3 100644
--- a/app/features/utils/functions.js
+++ b/app/features/utils/functions.js
@@ -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.
diff --git a/app/i18n/lang/en.json b/app/i18n/lang/en.json
index 20e42de..df26637 100644
--- a/app/i18n/lang/en.json
+++ b/app/i18n/lang/en.json
@@ -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)"
diff --git a/app/i18n/lang/es.json b/app/i18n/lang/es.json
index a6c3ae5..cea54bc 100644
--- a/app/i18n/lang/es.json
+++ b/app/i18n/lang/es.json
@@ -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)"
}
diff --git a/app/i18n/lang/fr.json b/app/i18n/lang/fr.json
index 73394bb..e1c91ca 100644
--- a/app/i18n/lang/fr.json
+++ b/app/i18n/lang/fr.json
@@ -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)"
}
diff --git a/app/i18n/lang/hu.json b/app/i18n/lang/hu.json
index 1330208..0a3ea76 100644
--- a/app/i18n/lang/hu.json
+++ b/app/i18n/lang/hu.json
@@ -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)"
diff --git a/app/i18n/lang/it.json b/app/i18n/lang/it.json
index b015313..8352454 100644
--- a/app/i18n/lang/it.json
+++ b/app/i18n/lang/it.json
@@ -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)"
}
diff --git a/app/i18n/lang/ru.json b/app/i18n/lang/ru.json
index abb85fe..8af1f43 100644
--- a/app/i18n/lang/ru.json
+++ b/app/i18n/lang/ru.json
@@ -31,7 +31,7 @@
"alwaysOnTopWindow": "Поверх всех окон",
"startWithAudioMuted": "Начать без звука",
"startWithVideoMuted": "Начать без видео",
- "invalidServer": "Неверный URL-адрес сервера или внешний API не включен",
+ "invalidServer": "Неверный URL-адрес сервера",
"serverUrl": "URL-адрес сервера",
"serverTimeout": "Тайм-аут сервера (в секундах)"
}