Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion extension-ready/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,9 @@ document.addEventListener('DOMContentLoaded', async () => {
const li = text.match(/(?:https?:\/\/)?(?:www\.)?linkedin\.com\/in\/[\w-]+\/?/i);
const gh = text.match(/(?:https?:\/\/)?(?:www\.)?github\.com\/[\w-]+\/?/i);
const tw = text.match(/(?:https?:\/\/)?(?:www\.)?(?:twitter|x)\.com\/[\w-]+\/?/i);
const web = text.match(/\b(?:https?:\/\/|www\.)(?!(?:www\.)?(?:linkedin|github|twitter|x)\.com\b)[\w.-]+\.[a-z]{2,}(?:\/[\w./-]*)?/i);
const web = text.match(
/(?<!@)\b(?:(?:https?:\/\/|www\.)?(?!(?:www\.)?(?:linkedin|github|twitter|x)\.com\b)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}(?:\/[a-z0-9\-._~:/?#[\]@!$&'()*+,;=%]*)?)/i
);
return {
linkedin: ensure(li?.[0]),
github: ensure(gh?.[0]),
Expand Down
22 changes: 22 additions & 0 deletions tests/popup-stats-ui.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs';
import vm from 'node:vm';
import { describe, expect, it } from 'vitest';

const popupHtml = fs.readFileSync(new URL('../extension-ready/popup.html', import.meta.url), 'utf8');
Expand All @@ -7,6 +8,14 @@ const contentJs = fs.readFileSync(new URL('../extension-ready/content.js', impor
const contentCss = fs.readFileSync(new URL('../extension-ready/content.css', import.meta.url), 'utf8');
const backgroundJs = fs.readFileSync(new URL('../extension-ready/background.js', import.meta.url), 'utf8');

function loadExtractCvContactUrls() {
const match = popupJs.match(/function extractCvContactUrls\(text\) \{[\s\S]*?\n \}/);
if (!match) throw new Error('extractCvContactUrls not found');
const sandbox = {};
vm.runInNewContext(`${match[0]}\nglobalThis.__extractCvContactUrls = extractCvContactUrls;`, sandbox);
return sandbox.__extractCvContactUrls;
}

describe('popup productivity stats UI', () => {
it('renders the empty collapsed state', () => {
expect(popupHtml).toContain('id="stats-summary">No activity yet</span>');
Expand Down Expand Up @@ -90,4 +99,17 @@ describe('popup productivity stats UI', () => {
expect(contentJs).toContain('labelTextWithoutControls');
expect(contentJs).toContain("field.closest?.('label')");
});

it('extracts bare portfolio domains without treating emails as websites', () => {
const extractCvContactUrls = loadExtractCvContactUrls();
const urls = extractCvContactUrls(`Jane Doe
jane@example.xyz
linkedin.com/in/janedoe
github.com/janedoe
portfolio.xyz/work`);

expect(urls.linkedin).toBe('https://linkedin.com/in/janedoe');
expect(urls.github).toBe('https://github.com/janedoe');
expect(urls.website).toBe('https://portfolio.xyz/work');
});
});
Loading