From a09f6fea0a9d754ad4666a968c290ffa61bca8e1 Mon Sep 17 00:00:00 2001 From: alexfront Date: Thu, 13 Aug 2020 12:50:05 +0300 Subject: [PATCH] Improve isUrl validator Allowing to check http(s) and format without domain like http://localhost:8080 Signed-off-by: alexfront --- src/renderer/components/input/input.validators.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/components/input/input.validators.ts b/src/renderer/components/input/input.validators.ts index 7db0934d4f..2236265e5d 100644 --- a/src/renderer/components/input/input.validators.ts +++ b/src/renderer/components/input/input.validators.ts @@ -38,7 +38,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\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/), + validate: value => !!value.match(/^http(s)?:\/\/\w+(\.\w+)*(:[0-9]+)?\/?(\/[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]*)*$/), }; export const minLength: Validator = {