aboutsummaryrefslogtreecommitdiff
path: root/app/features/welcome/components/Welcome.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/features/welcome/components/Welcome.js')
-rw-r--r--app/features/welcome/components/Welcome.js36
1 files changed, 27 insertions, 9 deletions
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;