From 4898742ee95e66ffea095beb2b77d5fbcd20f000 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Wed, 12 Jun 2024 18:18:14 +0200 Subject: [PATCH] Fix http://localhost:3000/ url validation case (#388) * Fix http://localhost:3000/ url validation case * adjust min regex occurrences --- src/utils/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 11cd0394..484ef65b 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -60,7 +60,7 @@ export const validator = { isValidUrl: (urlString: string) => { const urlPattern = new RegExp( "^(https?:\\/\\/)?" + // validate protocol - "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|" + // validate domain name + "((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|localhost|" + // validate domain name "((\\d{1,3}\\.){3}\\d{1,3}))" + // validate OR ip (v4) address "(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*" + // validate port and path "(\\?[;&a-z\\d%_.~+=-]*)?" + // validate query string