comment server selector - create file for protocol regex
This commit is contained in:
parent
cbc3624664
commit
2e048dc225
3 changed files with 9 additions and 16 deletions
|
@ -11,13 +11,6 @@ type Props = {
|
|||
serverDetails: CommentServerDetails,
|
||||
};
|
||||
|
||||
/*
|
||||
[ https://myserver.com x ]
|
||||
[ https://myserver.com x (selected)]
|
||||
|
||||
[ https://myserver.com:50001 x (selected)]
|
||||
*/
|
||||
|
||||
const InputTogglePanel = (props: Props) => {
|
||||
const { onClick, active, serverDetails, onRemove } = props;
|
||||
|
||||
|
|
|
@ -2,21 +2,13 @@
|
|||
import React, { useState, useEffect } from 'react';
|
||||
import Button from 'component/button';
|
||||
import { Form, FormField } from 'component/common/form';
|
||||
import { VALID_IPADDRESS_REGEX, VALID_HOSTNAME_REGEX, VALID_ENDPOINT_REGEX } from 'constants/protocol_regex';
|
||||
|
||||
type Props = {
|
||||
update: (CommentServerDetails) => 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 si = serverString.indexOf('/');
|
||||
const pi = serverString.indexOf(':');
|
||||
|
|
8
ui/constants/protocol_regex.js
Normal file
8
ui/constants/protocol_regex.js
Normal 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]+))+$');
|
Loading…
Reference in a new issue