Fix company creation duplicate on email sync after introducing links type (#6460)
- Introduce `extractDomainFromLink` - Use is inside `create-company.service`
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
import { extractDomainFromLink } from 'src/modules/contact-creation-manager/utils/extract-domain-from-link.util';
|
||||
|
||||
describe('extractDomainFromLink', () => {
|
||||
it('should extract domain from link', () => {
|
||||
const link = 'https://www.twenty.com';
|
||||
const result = extractDomainFromLink(link);
|
||||
|
||||
expect(result).toBe('twenty.com');
|
||||
});
|
||||
|
||||
it('should extract domain from link without www', () => {
|
||||
const link = 'https://twenty.com';
|
||||
const result = extractDomainFromLink(link);
|
||||
|
||||
expect(result).toBe('twenty.com');
|
||||
});
|
||||
|
||||
it('should extract domain from link without protocol', () => {
|
||||
const link = 'twenty.com';
|
||||
const result = extractDomainFromLink(link);
|
||||
|
||||
expect(result).toBe('twenty.com');
|
||||
});
|
||||
|
||||
it('should extract domain from link with path', () => {
|
||||
const link = 'https://twenty.com/about';
|
||||
const result = extractDomainFromLink(link);
|
||||
|
||||
expect(result).toBe('twenty.com');
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,5 @@
|
||||
export const extractDomainFromLink = (link: string) => {
|
||||
const domain = link.replace(/^(https?:\/\/)?(www\.)?/i, '').split('/')[0];
|
||||
|
||||
return domain;
|
||||
};
|
||||
Reference in New Issue
Block a user