diff --git a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx index fa47d4928..3090dfaa4 100644 --- a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx +++ b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx @@ -48,6 +48,7 @@ export const RecordChip = ({ const recordIndexOpenRecordIn = useRecoilValue(recordIndexOpenRecordInState); // TODO temporary until we create a record show page for Workspaces members + if ( forceDisableClick || objectNameSingular === CoreObjectNameSingular.WorkspaceMember @@ -61,7 +62,7 @@ export const RecordChip = ({ avatarType={recordChipData.avatarType} avatarUrl={recordChipData.avatarUrl ?? ''} className={className} - variant={ChipVariant.Static} + variant={ChipVariant.Transparent} /> ); } diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ActorFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ActorFieldDisplay.tsx index 530b92b58..f0c35b7fe 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ActorFieldDisplay.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ActorFieldDisplay.tsx @@ -12,6 +12,7 @@ export const ActorFieldDisplay = () => { } const { fieldValue, name, avatarUrl } = actorFieldDisplay; + return displayActorField ? ( { it('should throw an error if domain part is empty', () => { expect(() => getDomainNameByEmail('user@')).toThrow('Invalid email format'); }); + + // Edge cases with weird but potentially valid email formats + it('should handle email with plus addressing', () => { + expect(getDomainNameByEmail('user+tag@example.com')).toBe('example.com'); + }); + + it('should handle email with dots in local part', () => { + expect(getDomainNameByEmail('user.name@example.com')).toBe('example.com'); + }); + + it('should handle email with subdomain', () => { + expect(getDomainNameByEmail('user@mail.example.com')).toBe( + 'mail.example.com', + ); + }); + + it('should handle email with numeric domain', () => { + expect(getDomainNameByEmail('user@123.456.1.2')).toBe('123.456.1.2'); + }); + + it('should handle email with hyphenated domain', () => { + expect(getDomainNameByEmail('user@my-domain.com')).toBe('my-domain.com'); + }); + + it('should handle email with international domain (punycode)', () => { + expect(getDomainNameByEmail('user@xn--nxasmq6b.com')).toBe( + 'xn--nxasmq6b.com', + ); + }); + + it('should handle email with very long domain', () => { + const longDomain = 'a'.repeat(160) + '.com'; + + expect(getDomainNameByEmail(`user@${longDomain}`)).toBe(longDomain); + }); + + it('should handle email with quoted local part containing spaces', () => { + expect(getDomainNameByEmail('"user name"@example.com')).toBe('example.com'); + }); + + xit('should handle email with special characters in quoted local part', () => { + expect(getDomainNameByEmail('"user@#$%"@example.com')).toBe('example.com'); + }); + + xit('should handle email with quoted local part containing @', () => { + expect(getDomainNameByEmail('"user@local"@example.com')).toBe( + 'example.com', + ); + }); }); diff --git a/packages/twenty-server/src/utils/get-domain-name-by-email.ts b/packages/twenty-server/src/utils/get-domain-name-by-email.ts index ed1b8a7c2..0261fa4b1 100644 --- a/packages/twenty-server/src/utils/get-domain-name-by-email.ts +++ b/packages/twenty-server/src/utils/get-domain-name-by-email.ts @@ -1,18 +1,20 @@ +import { isNonEmptyString } from '@sniptt/guards'; + export const getDomainNameByEmail = (email: string) => { - if (!email) { + if (!isNonEmptyString(email)) { throw new Error('Email is required'); } const fields = email.split('@'); if (fields.length !== 2) { - throw new Error('Invalid email format'); + throw new Error(`Invalid email format (${fields.length - 1} @) ${email}`); } const domain = fields[1]; if (!domain) { - throw new Error('Invalid email format'); + throw new Error(`Invalid email format (no domain) ${email}`); } return domain;