Updated regex for isUrl to allow for an empty string (#1049)

Updated regex for isUrl to allow for an empty string aswell as a correct URL.

Signed-off-by: Steve Richards <srichards@mirantis.com>

Co-authored-by: Steve Richards <srichards@mirantis.com>
This commit is contained in:
steve richardsandSteve Richards authored and GitHub committed 2020-10-14 14:34:04 +03:00
1 parent 38796e582b
commit db9af88d91
1 file changed
+1 -1
@@ -39,7 +39,7 @@ export const isNumber: Validator = {
export const isUrl: Validator = {
condition: ({ type }) => type === "url",
message: () => _i18n._(t`Wrong url format`),
validate: value => !!value.match(/^http(s)?:\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)*$/),
validate: value => !!value.match(/^$|^http(s)?:\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)*$/),
};
export const isPath: Validator = {