diff --git a/packages/shared/src/components/profile/SocialLinksInput.spec.tsx b/packages/shared/src/components/profile/SocialLinksInput.spec.tsx index c9c8714e532..eed02a8e1dc 100644 --- a/packages/shared/src/components/profile/SocialLinksInput.spec.tsx +++ b/packages/shared/src/components/profile/SocialLinksInput.spec.tsx @@ -86,6 +86,36 @@ describe('SocialLinksInput', () => { ); }); + it('stores unrecognized domains as generic links', async () => { + const onSubmit = jest.fn(); + render(); + + await userEvent.type( + screen.getByPlaceholderText('Paste a URL (e.g., github.com/username)'), + 'https://dabworx.com', + ); + + expect(screen.queryByText('X detected')).not.toBeInTheDocument(); + + await userEvent.click(screen.getByRole('button', { name: 'Add' })); + + expect(await screen.findByText('Link')).toBeVisible(); + expect(screen.queryByText('X')).not.toBeInTheDocument(); + + await userEvent.click(screen.getByRole('button', { name: 'Save' })); + + await waitFor(() => + expect(onSubmit).toHaveBeenCalledWith({ + socialLinks: [ + { + platform: 'other', + url: 'https://dabworx.com', + }, + ], + }), + ); + }); + it('blocks submit and renders an inline error for invalid pending text', async () => { const onSubmit = jest.fn(); render(); diff --git a/packages/shared/src/features/organizations/utils/platformDetection.spec.ts b/packages/shared/src/features/organizations/utils/platformDetection.spec.ts new file mode 100644 index 00000000000..e3a12c8a717 --- /dev/null +++ b/packages/shared/src/features/organizations/utils/platformDetection.spec.ts @@ -0,0 +1,22 @@ +import { OrganizationLinkType } from '../types'; +import { detectPlatform } from './platformDetection'; + +describe('detectPlatform', () => { + it('should detect TechCrunch press links by exact domain', () => { + expect(detectPlatform('https://techcrunch.com/2026/09/21/story')).toEqual({ + platform: 'TechCrunch', + socialType: null, + linkType: OrganizationLinkType.Press, + defaultLabel: 'Press Release', + }); + }); + + it('should not detect press domains by substring', () => { + expect( + detectPlatform('https://mytechcrunch.com/2026/09/21/story'), + ).toBeNull(); + expect( + detectPlatform('https://techcrunch.com.attacker.example/story'), + ).toBeNull(); + }); +}); diff --git a/packages/shared/src/features/organizations/utils/platformDetection.tsx b/packages/shared/src/features/organizations/utils/platformDetection.tsx index 7222ee2c2b1..302347b0056 100644 --- a/packages/shared/src/features/organizations/utils/platformDetection.tsx +++ b/packages/shared/src/features/organizations/utils/platformDetection.tsx @@ -9,6 +9,7 @@ import { detectPlatformFromUrl, getPlatformIconElement, getPlatformLabel as getGenericPlatformLabel, + matchesDomain, } from '../../../lib/platforms'; export type LinkItem = { @@ -89,7 +90,7 @@ const isPressUrl = (url: string): boolean => { try { const parsed = new URL(url.startsWith('http') ? url : `https://${url}`); const hostname = parsed.hostname.replace(/^(www\.|m\.|mobile\.)/, ''); - return PRESS_DOMAINS.some((domain) => hostname.includes(domain)); + return PRESS_DOMAINS.some((domain) => matchesDomain(hostname, domain)); } catch { return false; } diff --git a/packages/shared/src/features/profile/components/AboutMe.tsx b/packages/shared/src/features/profile/components/AboutMe.tsx index cbf7c00558f..1d0c8ae84f9 100644 --- a/packages/shared/src/features/profile/components/AboutMe.tsx +++ b/packages/shared/src/features/profile/components/AboutMe.tsx @@ -61,7 +61,7 @@ export function AboutMe({ {shouldShowSocialLinks && (
{socialLinks.map((link) => ( - +