+ client: Validate adding of absolute path to the filtering lists
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { Trans } from 'react-i18next';
|
||||
import PropTypes from 'prop-types';
|
||||
import { R_IPV4, R_MAC, R_HOST, R_IPV6, R_CIDR, R_CIDR_IPV6, UNSAFE_PORTS, R_URL_REQUIRES_PROTOCOL } from '../helpers/constants';
|
||||
import {
|
||||
R_IPV4, R_MAC, R_HOST, R_IPV6, R_CIDR, R_CIDR_IPV6,
|
||||
UNSAFE_PORTS, R_URL_REQUIRES_PROTOCOL, R_WIN_ABSOLUTE_PATH, R_UNIX_ABSOLUTE_PATH,
|
||||
} from '../helpers/constants';
|
||||
import { createOnBlurHandler } from './helpers';
|
||||
|
||||
export const renderField = (props, elementType) => {
|
||||
@@ -289,4 +292,14 @@ export const isValidUrl = (value) => {
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const isValidAbsolutePath = value => R_WIN_ABSOLUTE_PATH.test(value)
|
||||
|| R_UNIX_ABSOLUTE_PATH.test(value);
|
||||
|
||||
export const isValidPath = (value) => {
|
||||
if (value && !isValidAbsolutePath(value) && !R_URL_REQUIRES_PROTOCOL.test(value)) {
|
||||
return <Trans>form_error_url_or_path_format</Trans>;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const toNumber = value => value && parseInt(value, 10);
|
||||
|
||||
Reference in New Issue
Block a user