comment server selector - create file for protocol regex

This commit is contained in:
zeppi 2022-02-03 10:44:26 -05:00 committed by jessopb
parent cbc3624664
commit 2e048dc225
3 changed files with 9 additions and 16 deletions

View file

@ -11,13 +11,6 @@ type Props = {
serverDetails: CommentServerDetails, serverDetails: CommentServerDetails,
}; };
/*
[ https://myserver.com x ]
[ https://myserver.com x (selected)]
[ https://myserver.com:50001 x (selected)]
*/
const InputTogglePanel = (props: Props) => { const InputTogglePanel = (props: Props) => {
const { onClick, active, serverDetails, onRemove } = props; const { onClick, active, serverDetails, onRemove } = props;

View file

@ -2,21 +2,13 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import Button from 'component/button'; import Button from 'component/button';
import { Form, FormField } from 'component/common/form'; import { Form, FormField } from 'component/common/form';
import { VALID_IPADDRESS_REGEX, VALID_HOSTNAME_REGEX, VALID_ENDPOINT_REGEX } from 'constants/protocol_regex';
type Props = { type Props = {
update: (CommentServerDetails) => void, update: (CommentServerDetails) => void,
onCancel: (boolean) => void, onCancel: (boolean) => void,
}; };
const VALID_IPADDRESS_REGEX = new RegExp(
'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\.)){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
);
const VALID_HOSTNAME_REGEX = new RegExp(
'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(\\.))+([A-Za-z]|[A-Za-z][A-Za-z]*[A-Za-z])$'
);
const VALID_ENDPOINT_REGEX = new RegExp('^((\\/)([a-zA-Z0-9]+))+$');
const isValidServerString = (serverString) => { const isValidServerString = (serverString) => {
const si = serverString.indexOf('/'); const si = serverString.indexOf('/');
const pi = serverString.indexOf(':'); const pi = serverString.indexOf(':');

View file

@ -0,0 +1,8 @@
export const VALID_IPADDRESS_REGEX = new RegExp(
'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\.)){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'
);
export const VALID_HOSTNAME_REGEX = new RegExp(
'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(\\.))+([A-Za-z]|[A-Za-z][A-Za-z]*[A-Za-z])$'
);
export const VALID_ENDPOINT_REGEX = new RegExp('^((\\/)([a-zA-Z0-9]+))+$');