fix(jobnet-search): keep canonical portal url and emit destination in applyUrl (closes #701) (#706)

* fix(jobnet-search): keep canonical portal url and emit destination in applyUrl (closes #701)

* docs(jobnet-search): document canonical url and applyUrl split (#701)

* changelog: place the #706 entry under [Unreleased]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Mads Lorentzen <madslorentzen_17@hotmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-10-21 07:09:02 +02:00
1 parent c71c270765
commit 183c8fda20
4 files changed
+41 -16

No files matched your search

@@ -99,8 +99,9 @@ export function occupationId(value: string): string {
/**
* Return the destination URL for an external ad, if it has a valid http(s)
* jobAdUrl. Only an absolute http(s) URL is used: the value is employer-supplied
* and downstream steps fetch it. Anything else returns null and the caller keeps
* the jobnet.dk route to preserve a unique URL for /scrape deduplication.
* and downstream steps fetch it. Emitted in `applyUrl` (and `jobAdUrl`); `url`
* always keeps the canonical jobnet.dk route across all postings. Anything
* else returns null.
*/
export function externalAdUrl(job: Pick<JobAdRaw, "isExternal" | "jobAdUrl">): string | null {
const raw = job.jobAdUrl?.trim()
@@ -140,6 +141,9 @@ export function createSearchOutput(data: SearchApiResponse, flags: SearchFlags)
// /scrape contract aliases (add-portal.md: every result carries at least
// id, title, company, location, date, url). `id` is the jobAdId - the
// value `detail` takes - under the name every other portal CLI uses.
// `url` stays canonical on jobnet.dk for all postings (internal and external)
// so deduplication, health checks, and /apply host routing (#562) identify
// the portal correctly; external ATS destinations are emitted as `applyUrl`.
id: job.jobAdId,
company: job.hiringOrgName,
location: job.postalDistrictName ?? job.municipality ?? null,
@@ -147,7 +151,8 @@ export function createSearchOutput(data: SearchApiResponse, flags: SearchFlags)
deadline: job.applicationDeadline && !job.applicationDeadline.startsWith("1900-01-01")
? job.applicationDeadline.slice(0, 10)
: null,
url: destination ?? `https://jobnet.dk/find-job/${job.jobAdId}`,
url: `https://jobnet.dk/find-job/${job.jobAdId}`,
applyUrl: destination,
}
})