diff --git a/packages/twenty-apps/community/linkedin-browser-extension/browser-extension/src/entrypoints/popup/app.tsx b/packages/twenty-apps/community/linkedin-browser-extension/browser-extension/src/entrypoints/popup/app.tsx index c1f0566ade..a4e59a1b6e 100644 --- a/packages/twenty-apps/community/linkedin-browser-extension/browser-extension/src/entrypoints/popup/app.tsx +++ b/packages/twenty-apps/community/linkedin-browser-extension/browser-extension/src/entrypoints/popup/app.tsx @@ -12,19 +12,28 @@ function App() { useEffect(() => { browser.tabs.query({ active: true, currentWindow: true }, function(tabs) { const currentTab = tabs[0]; - if(currentTab.url?.includes('https://www.linkedin.com/in')) { - sendMessage('getPersonviaRelay').then(data => { - setValue({...data, type: 'person' }) - }) - } - if(currentTab.url?.includes('https://www.linkedin.com/company')) { - sendMessage('getCompanyviaRelay').then(data => { - setValue({...data, type: 'company'}) - }) + if (!currentTab.url) { + return; + } + + let url = new URL(currentTab.url); + + const isLinkedinHost = + url.protocol === 'https:' && url.hostname === 'www.linkedin.com'; + + if (isLinkedinHost && url.pathname.startsWith('/in/')) { + sendMessage('getPersonviaRelay').then((data) => { + setValue({ ...data, type: 'person' }); + }); + } + + if (isLinkedinHost && url.pathname.startsWith('/company/')) { + sendMessage('getCompanyviaRelay').then((data) => { + setValue({ ...data, type: 'company' }); + }); } }); - }, []); const isPersonValue = (val: Value): val is PersonValue => { @@ -38,25 +47,29 @@ function App() { return (

{JSON.stringify(value)}

- { - isPersonValue(value) && - - } - { - isCompanyValue(value) && - - } + {isPersonValue(value) && ( + + )} + {isCompanyValue(value) && ( + + )}
); }