aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshit Kr Nagpal <akshitkrnagpal@gmail.com>2018-06-25 13:52:15 +0530
committerSaúl Ibarra Corretgé <s@saghul.net>2018-06-25 16:40:43 +0200
commitd73f80e7bffdfbbd3e5263033697640303957ba7 (patch)
tree365a55e0832687a1bf695ff3c7662ea8d9dcfcc9
parentf886f033f2883d2798414f07e057b3f0ace606e5 (diff)
Refactor handling of domain
Use the concept of a "server URL", since it's URLs we are dealing with, not actul domains.
-rw-r--r--app/features/app/components/App.js2
-rw-r--r--app/features/conference/components/Conference.js23
-rw-r--r--app/features/config/index.js4
-rw-r--r--app/features/router/history.js4
-rw-r--r--app/features/welcome/components/Welcome.js36
5 files changed, 45 insertions, 24 deletions
diff --git a/app/features/app/components/App.js b/app/features/app/components/App.js
index 392cd78..b934ddf 100644
--- a/app/features/app/components/App.js
+++ b/app/features/app/components/App.js
@@ -43,7 +43,7 @@ export default class App extends Component<*> {
path = '/' />
<Route
component = { Conference }
- path = '/:domain?/:room' />
+ path = '/conference' />
</Switch>
</Router>
</AtlasKitThemeProvider>
diff --git a/app/features/conference/components/Conference.js b/app/features/conference/components/Conference.js
index f308ef0..49950fb 100644
--- a/app/features/conference/components/Conference.js
+++ b/app/features/conference/components/Conference.js
@@ -4,6 +4,7 @@ import React, { Component } from 'react';
import type { Dispatch } from 'redux';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
+import URL from 'url';
import {
RemoteControl,
@@ -26,10 +27,9 @@ type Props = {
dispatch: Dispatch<*>;
/**
- * React Router match object.
- * This contains parameters passed through <Route /> component.
+ * React Router location object.
*/
- match: Object;
+ location: Object;
/**
* Avatar URL.
@@ -80,15 +80,16 @@ class Conference extends Component<Props, *> {
*/
componentDidMount() {
const parentNode = this._ref.current;
- const room = this.props.match.params.room;
- const domain = this.props.match.params.domain || config.defaultDomain;
+ const room = this.props.location.state.room;
+ const serverURL = this.props.location.state.serverURL
+ || config.defaultServerURL;
const script = document.createElement('script');
script.async = true;
- script.onload = () => this._onScriptLoad(parentNode, room, domain);
+ script.onload = () => this._onScriptLoad(parentNode, room, serverURL);
script.onerror = () => this._navigateToHome();
- script.src = `https://${domain}/external_api.js`;
+ script.src = `${serverURL}/external_api.js`;
this._ref.current.appendChild(script);
}
@@ -148,13 +149,15 @@ class Conference extends Component<Props, *> {
*
* @param {Object} parentNode - Node to which iframe has to be attached.
* @param {string} roomName - Conference room name to be joined.
- * @param {string} domain - Jitsi Meet server domain.
+ * @param {string} serverURL - Jitsi Meet server url.
* @returns {void}
*/
- _onScriptLoad(parentNode: Object, roomName: string, domain: string) {
+ _onScriptLoad(parentNode: Object, roomName: string, serverURL: string) {
const JitsiMeetExternalAPI = window.JitsiMeetExternalAPI;
- this._api = new JitsiMeetExternalAPI(domain, {
+ const { host } = URL.parse(serverURL);
+
+ this._api = new JitsiMeetExternalAPI(host, {
parentNode,
roomName
});
diff --git a/app/features/config/index.js b/app/features/config/index.js
index 6da1239..4be9486 100644
--- a/app/features/config/index.js
+++ b/app/features/config/index.js
@@ -6,9 +6,9 @@ export default {
appName: 'Jitsi Meet',
/**
- * The domain of the Jitsi Meet deployment that will be used.
+ * The default server URL of Jitsi Meet Deployment that will be used.
*/
- defaultDomain: 'meet.jit.si',
+ defaultServerURL: 'https://meet.jit.si/',
/**
* URL to send feedback.
diff --git a/app/features/router/history.js b/app/features/router/history.js
index 051b1d1..9434d7c 100644
--- a/app/features/router/history.js
+++ b/app/features/router/history.js
@@ -1,5 +1,5 @@
// @flow
-import { createHashHistory } from 'history';
+import { createMemoryHistory as createHistory } from 'history';
-export default createHashHistory();
+export default createHistory();
diff --git a/app/features/welcome/components/Welcome.js b/app/features/welcome/components/Welcome.js
index 63f79c5..663bc80 100644
--- a/app/features/welcome/components/Welcome.js
+++ b/app/features/welcome/components/Welcome.js
@@ -9,7 +9,6 @@ import React, { Component } from 'react';
import type { Dispatch } from 'redux';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
-import URL from 'url';
import { Navbar } from '../../navbar';
@@ -109,18 +108,37 @@ class Welcome extends Component<Props, State> {
* @returns {void}
*/
_onJoin() {
- const url = URL.parse(this.state.url);
+ const inputURL = this.state.url;
+ const lastIndexOfSlash = inputURL.lastIndexOf('/');
+ let room;
+ let serverURL;
+
+ if (lastIndexOfSlash === -1) {
+ // This must be only the room name.
+ room = inputURL;
+ } else {
+ // Take the substring after last slash to be the room name.
+ room = inputURL.substring(lastIndexOfSlash + 1);
- // Check if the parsed url is a full url or just room name.
- if (url.host && url.path) {
+ // Take the substring before last slash to be the Server URL.
+ serverURL = inputURL.substring(0, lastIndexOfSlash);
- // This will be triggered when the full url is present.
- this.props.dispatch(push(url.host + url.path));
- } else {
+ // If no protocol is specified in the input we assume and append
+ // the HTTPS protocol scheme.
+ if (serverURL.indexOf('://') === -1) {
+ serverURL = `https://${serverURL}`;
+ }
+ }
- // Directly to the the path.
- this.props.dispatch(push(url.path));
+ // Don't navigate if no room was specified.
+ if (!room) {
+ return;
}
+
+ this.props.dispatch(push('/conference', {
+ room,
+ serverURL
+ }));
}
_onURLChange: (*) => void;