fix: Fixed API typo and webhook checkerror (#6779)
## Issue 1.There was an Api typo with API under Developers section #6778 2. Webhook lacked an check method for the `TextInput` #6774 ## After- <img width="649" alt="Screenshot 2024-08-29 at 2 13 21 AM" src="https://github.com/user-attachments/assets/bc9595f8-533f-430e-bc18-56373983eec8"> https://github.com/user-attachments/assets/8e2b06bc-308a-48ad-8ecb-9d0a130877bc --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
import { isValidUrl } from '../isValidUrl';
|
||||
|
||||
describe('isValidUrl', () => {
|
||||
it('test cases', () => {
|
||||
// Truthy
|
||||
expect(isValidUrl('https://www.example.com')).toBe(true);
|
||||
expect(isValidUrl('http://192.168.2.0:3000')).toBe(true);
|
||||
expect(isValidUrl('http://localhost')).toBe(true);
|
||||
expect(isValidUrl('http://localhost:3000')).toBe(true);
|
||||
expect(isValidUrl('http://subdomain.example.com')).toBe(true);
|
||||
expect(isValidUrl('https://www.example.com/path')).toBe(true);
|
||||
expect(isValidUrl('https://www.example.com/path/path2?query=123')).toBe(
|
||||
true,
|
||||
);
|
||||
expect(isValidUrl('http://localhost:3000')).toBe(true);
|
||||
expect(isValidUrl('example.com')).toBe(true);
|
||||
expect(isValidUrl('www.subdomain.example.com')).toBe(true);
|
||||
|
||||
// Falsy
|
||||
expect(isValidUrl('?o')).toBe(false);
|
||||
expect(isValidUrl('')).toBe(false);
|
||||
expect(isValidUrl('\\')).toBe(false);
|
||||
expect(isValidUrl('wwwexamplecom')).toBe(false);
|
||||
});
|
||||
});
|
||||
8
packages/twenty-front/src/utils/url/isValidUrl.ts
Normal file
8
packages/twenty-front/src/utils/url/isValidUrl.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export const isValidUrl = (url: string) => {
|
||||
const urlRegex =
|
||||
/^(https?:\/\/)?((([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,})|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(localhost))(:\d+)?(\/[^\s]*)?(\?[^\s]*)?$/;
|
||||
|
||||
const urlPattern = new RegExp(urlRegex, 'i');
|
||||
|
||||
return !!urlPattern.test(url);
|
||||
};
|
||||
Reference in New Issue
Block a user