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? // Server URL entered?
if (serverUrl.length === 0) { if (serverUrl.length === 0) {
window.pushToast({
title: window.i18n('noServerURL'),
type: 'error',
id: 'connectToServerFail',
});
return; return;
} }

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

Loading…
Cancel
Save