diff --git a/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx b/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx index c83640d9dfcb..ba471414b551 100644 --- a/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx +++ b/packages/twenty-front/src/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew.tsx @@ -12,7 +12,6 @@ import { TextInput } from '@/ui/input/components/TextInput'; import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'; import { Section } from '@/ui/layout/section/components/Section'; import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb'; -import { isURL } from '~/utils/is-url'; export const SettingsDevelopersWebhooksNew = () => { const navigate = useNavigate(); @@ -23,18 +22,10 @@ export const SettingsDevelopersWebhooksNew = () => { targetUrl: '', operation: '*.*', }); - const [errorMessage, setErrorMessage] = useState(); const { createOneRecord: createOneWebhook } = useCreateOneRecord({ objectNameSingular: CoreObjectNameSingular.Webhook, }); const handleSave = async () => { - setErrorMessage(undefined); - - if (!isURL(formValues.targetUrl)) { - setErrorMessage('Invalid webhook URL'); - return; - } - const newWebhook = await createOneWebhook?.(formValues); if (!newWebhook) { @@ -80,7 +71,6 @@ export const SettingsDevelopersWebhooksNew = () => { targetUrl: value, })); }} - error={errorMessage} fullWidth /> diff --git a/packages/twenty-front/src/utils/__tests__/is-url.test.ts b/packages/twenty-front/src/utils/__tests__/is-url.test.ts deleted file mode 100644 index a31cf05240b2..000000000000 --- a/packages/twenty-front/src/utils/__tests__/is-url.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { isURL } from '~/utils/is-url'; - -describe('isURL', () => { - it(`should return false if null`, () => { - expect(isURL(null)).toBeFalsy(); - }); - - it(`should return false if undefined`, () => { - expect(isURL(undefined)).toBeFalsy(); - }); - - it(`should return true if string google`, () => { - expect(isURL('google')).toBeFalsy(); - }); - - it(`should return true if string google.com`, () => { - expect(isURL('google.com')).toBeTruthy(); - }); - - it(`should return true if string bbc.co.uk`, () => { - expect(isURL('bbc.co.uk')).toBeTruthy(); - }); - - it(`should return true if string web.io`, () => { - expect(isURL('web.io')).toBeTruthy(); - }); - - it(`should return true if string x.com`, () => { - expect(isURL('x.com')).toBeTruthy(); - }); - - it(`should return true if string 2.com`, () => { - expect(isURL('2.com')).toBeTruthy(); - }); - - it(`should return true if string https://2.com/test/`, () => { - expect(isURL('https://2.com/test/')).toBeTruthy(); - }); - - it(`should return true if string is https://www.linkedin.com/company/b%C3%B6ke-&-partner-sdft-partmbb/`, () => { - expect( - isURL( - 'https://www.linkedin.com/company/b%C3%B6ke-&-partner-sdft-partmbb/', - ), - ).toBeTruthy(); - }); - - it('should return true if the TLD is long', () => { - expect(isURL('https://example.travelinsurance')).toBeTruthy(); - }); - - it('should return true if the TLD is internationalized', () => { - // The longest TLD as of now - // https://stackoverflow.com/questions/9238640/how-long-can-a-tld-possibly-be - // curl -s http://data.iana.org/TLD/tlds-alpha-by-domain.txt \ - // | tail -n+2 \ - // | awk '{ print length, $0 }' \ - // | sort --numeric-sort --reverse \ - // | head -n 5 - expect(isURL('https://example.xn--vermgensberatung-pwb')).toBeTruthy(); - }); -}); diff --git a/packages/twenty-front/src/utils/is-url.ts b/packages/twenty-front/src/utils/is-url.ts deleted file mode 100644 index bb6e8f7ee613..000000000000 --- a/packages/twenty-front/src/utils/is-url.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { isDefined } from './isDefined'; - -export const isURL = (url: string | undefined | null) => - isDefined(url) && - url.match( - /^(https?:\/\/)?(www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/i, - );