From 2e21d55807d2a867b505ea31a822fdcf20b184ad Mon Sep 17 00:00:00 2001 From: rafapolo Date: Thu, 10 Sep 2026 10:39:51 +0200 Subject: [PATCH] fix: dedupe job-room.ch and jobs.ch links stored without a protocol The link column was matched by an http(s):// pattern, but job-room.ch and jobs.ch links are stored without a protocol (e.g. "www.jobs.ch/de/..."), so the pattern silently skipped every one of them and re-added the same posting on every run. Read the link by CSV column position instead. --- index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 2515545..f63ccfa 100644 --- a/index.ts +++ b/index.ts @@ -40,13 +40,19 @@ if (csvExists) { } } -// Load existing links for deduplication +// Load existing links for deduplication. The link column (6th field) is +// pulled by position, not by an http(s):// match — job-room.ch/jobs.ch links +// are stored without a protocol (e.g. "www.jobs.ch/de/..."), so a URL-pattern +// match silently skipped every one of them and re-added the same jobs.ch +// posting on every run (found 2026-09-08: 4 duplicate rows for one link, +// added on both 09-07 and 09-08). const existingLinks = new Set(); try { const text = await Bun.file(CSV).text(); for (const line of text.split("\n").slice(1)) { - const url = line.match(/"(https?:\/\/[^"]+)"/)?.[1]; - if (url) existingLinks.add(url); + if (!line.trim()) continue; + const link = line.replace(/^"|"$/g, "").split('","')[5]; + if (link) existingLinks.add(link); } } catch { // first run