From 887e5c448e427a5166a17067850a5689e683f410 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Sun, 6 Oct 2024 21:38:17 +0200 Subject: [PATCH] refactor: allow messages not starting with http --- .../src/common/utils/__tests__/regex.test.ts | 14 +------------- apps/client/src/common/utils/regex.ts | 1 - .../panel/integrations-panel/HttpIntegrations.tsx | 1 - .../src/utils/__tests__/parserFunctions.test.ts | 1 - 4 files changed, 1 insertion(+), 16 deletions(-) diff --git a/apps/client/src/common/utils/__tests__/regex.test.ts b/apps/client/src/common/utils/__tests__/regex.test.ts index 7e34a7fad..e9206110f 100644 --- a/apps/client/src/common/utils/__tests__/regex.test.ts +++ b/apps/client/src/common/utils/__tests__/regex.test.ts @@ -1,4 +1,4 @@ -import { isAlphanumeric, isIPAddress, isNotEmpty, isOnlyNumbers, startsWithHttp, startsWithSlash } from '../regex'; +import { isAlphanumeric, isIPAddress, isNotEmpty, isOnlyNumbers, startsWithSlash } from '../regex'; describe('simple tests for regex', () => { test('isOnlyNumbers', () => { @@ -25,18 +25,6 @@ describe('simple tests for regex', () => { }); }); - test('startsWithHttp', () => { - const right = ['http://test']; - const wrong = ['https://test', 'testing', '123.0.1']; - - right.forEach((t) => { - expect(startsWithHttp.test(t)).toBe(true); - }); - wrong.forEach((t) => { - expect(startsWithHttp.test(t)).toBe(false); - }); - }); - test('startsWithSlash', () => { const right = ['//test']; const wrong = ['testing', '123.0.1']; diff --git a/apps/client/src/common/utils/regex.ts b/apps/client/src/common/utils/regex.ts index 3f4848350..2681f443f 100644 --- a/apps/client/src/common/utils/regex.ts +++ b/apps/client/src/common/utils/regex.ts @@ -5,7 +5,6 @@ export const isOnlyNumbers = /^\d+$/; export const isIPAddress = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/; -export const startsWithHttp = /^http:\/\//; export const startsWithSlash = /^\//; export const isAlphanumeric = /^[a-z0-9]+$/i; export const isASCII = /^[ -~]+$/; //https://catonmat.net/my-favorite-regex diff --git a/apps/client/src/features/app-settings/panel/integrations-panel/HttpIntegrations.tsx b/apps/client/src/features/app-settings/panel/integrations-panel/HttpIntegrations.tsx index d1d6adfc3..391f095fc 100644 --- a/apps/client/src/features/app-settings/panel/integrations-panel/HttpIntegrations.tsx +++ b/apps/client/src/features/app-settings/panel/integrations-panel/HttpIntegrations.tsx @@ -8,7 +8,6 @@ import { generateId } from 'ontime-utils'; import { maybeAxiosError } from '../../../../common/api/utils'; import { useHttpSettings, usePostHttpSettings } from '../../../../common/hooks-query/useHttpSettings'; import { isKeyEscape } from '../../../../common/utils/keyEvent'; -import { startsWithHttp } from '../../../../common/utils/regex'; import * as Panel from '../PanelUtils'; import { cycles } from './integrationUtils'; diff --git a/apps/server/src/utils/__tests__/parserFunctions.test.ts b/apps/server/src/utils/__tests__/parserFunctions.test.ts index a2515c1d6..a6983d2be 100644 --- a/apps/server/src/utils/__tests__/parserFunctions.test.ts +++ b/apps/server/src/utils/__tests__/parserFunctions.test.ts @@ -128,7 +128,6 @@ describe('parseHttp()', () => { { id: '1', cycle: 'onLoad', message: 'http://', enabled: true }, // OK {}, // no data { id: '2', cycle: 'onStart', enabled: true }, // no message - { id: '3', cycle: 'onLoad', message: '/test', enabled: true }, // doesnt start with http ], } as HttpSettings; const result = parseHttp({ http }, errorEmitter);