diff --git a/ui/component/common/input-radio-panel.jsx b/ui/component/common/input-radio-panel.jsx index 138534c54..a64d0a084 100644 --- a/ui/component/common/input-radio-panel.jsx +++ b/ui/component/common/input-radio-panel.jsx @@ -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; diff --git a/ui/component/settingCommentsServer/internal/input-radio-panel-addCommentServer.jsx b/ui/component/settingCommentsServer/internal/input-radio-panel-addCommentServer.jsx index ecbec3bce..e01ad140c 100644 --- a/ui/component/settingCommentsServer/internal/input-radio-panel-addCommentServer.jsx +++ b/ui/component/settingCommentsServer/internal/input-radio-panel-addCommentServer.jsx @@ -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(':'); diff --git a/ui/constants/protocol_regex.js b/ui/constants/protocol_regex.js new file mode 100644 index 000000000..8aa0e98c3 --- /dev/null +++ b/ui/constants/protocol_regex.js @@ -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]+))+$');