add regex url check before joining channel

pull/725/head
Audric Ackermann 6 years ago
parent 85235dd461
commit 8bfab92213

@ -503,7 +503,7 @@ label {
.message-selection-overlay {
display: none;
position: absolute;
right: 15px;
right: 10px;
left: 15px;
.close-button {

@ -302,6 +302,8 @@ export class LeftPaneChannelSection extends React.Component<Props, State> {
return false;
}
const regexURL = /(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?/;
if (channelUrlPasted.length <= 0) {
window.pushToast({
title: window.i18n('noServerURL'),
@ -312,6 +314,16 @@ export class LeftPaneChannelSection extends React.Component<Props, State> {
return false;
}
if (!regexURL.test(channelUrlPasted)) {
window.pushToast({
title: window.i18n('noServerURL'),
type: 'error',
id: 'connectToServerFail',
});
return false;
}
// TODO: Make this not hard coded
const channelId = 1;
this.setState({ loading: true });

Loading…
Cancel
Save