From 6f566ff6338a4e8e756085799b0cf8da70ee0b2a Mon Sep 17 00:00:00 2001 From: yaacov Date: Tue, 1 Aug 2023 16:51:39 +0300 Subject: [PATCH] Allow urls to start with numbers Signed-off-by: yaacov --- .../modules/Providers/utils/validators/__tests__/common.test.ts | 2 +- .../src/modules/Providers/utils/validators/common.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/forklift-console-plugin/src/modules/Providers/utils/validators/__tests__/common.test.ts b/packages/forklift-console-plugin/src/modules/Providers/utils/validators/__tests__/common.test.ts index 68638dbe6..9cb44eef8 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/utils/validators/__tests__/common.test.ts +++ b/packages/forklift-console-plugin/src/modules/Providers/utils/validators/__tests__/common.test.ts @@ -41,6 +41,7 @@ describe('validator', () => { 'https://example.com:8080/my/path?param=value', 'http://192.168.1.1:8000', 'https://www.example.co.uk', + 'https://1.www.example.co.uk', ]; for (const url of urls) { expect(validateURL(url)).toBe(true); @@ -50,7 +51,6 @@ describe('validator', () => { it('should return false for invalid URLs', () => { const urls = [ 'http:/example.com', // missing slash - 'https://192.168.1.1.1', // invalid IP 'http://example', // no TLD ]; for (const url of urls) { diff --git a/packages/forklift-console-plugin/src/modules/Providers/utils/validators/common.ts b/packages/forklift-console-plugin/src/modules/Providers/utils/validators/common.ts index 1b0c738fd..2d22e7806 100644 --- a/packages/forklift-console-plugin/src/modules/Providers/utils/validators/common.ts +++ b/packages/forklift-console-plugin/src/modules/Providers/utils/validators/common.ts @@ -13,7 +13,7 @@ const IMAGE_REGEX = new RegExp(`^${REGISTRY}?${IMAGE_NAME}((@${SHA256}|:${TAG})) // example: https://example.com/index const PROTOCOL = '(https?:\\/\\/)'; const IPV4 = '((?:[0-9]{1,3}\\.){3}[0-9]{1,3})'; -const HOSTNAME = '([a-zA-Z-_]+[a-zA-Z0-9-_]+\\.[a-zA-Z0-9-_\\.]+)'; +const HOSTNAME = '([a-zA-Z0-9-_]+\\.[a-zA-Z0-9-_\\.]+)'; const PORT = '(:[0-9]+)?'; const PATH = '(\\/[^ ]*)*'; const QUERY_PARAMS = '(\\?[a-zA-Z0-9=&_]*)?';