server-regex-tighten

pull/1225/head
Vincent 5 years ago
parent f6ae5386e9
commit 6111cb2d17

@ -448,12 +448,6 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
// Server URL entered?
if (serverUrl.length === 0) {
window.pushToast({
title: window.i18n('noServerURL'),
type: 'error',
id: 'connectToServerFail',
});
return;
}

@ -1,7 +1,5 @@
// This is the Open Group equivalent to the PubKey type.
import { LokiPublicChatFactoryInterface } from "../../../js/modules/loki_public_chat_api";
interface OpenGroupParams {
server: string;
channel: number;
@ -12,7 +10,7 @@ export class OpenGroup {
// Matches prefixes https:// http:// plus no prefix.
// Servers without prefix default to https://
private static readonly serverRegex = new RegExp(
'^(https?:\\/\\/){0,1}([\\w-]{2,}.){1,2}[\\w-]{2,}$'
'^((https?:\\/\\/){0,1})([\\w-]{2,}\\.){1,2}[\\w-]{2,}$'
);
private static readonly groupIdRegex = new RegExp(
'^publicChat:[0-9]*@([\\w-]{2,}.){1,2}[\\w-]{2,}$'
@ -38,11 +36,7 @@ export class OpenGroup {
}
public static validate(serverUrl: string): boolean {
if (this.serverRegex.test(serverUrl)) {
return true;
}
return false;
return this.serverRegex.test(serverUrl);
}
public static from(

Loading…
Cancel
Save