fix(jobdanmark-search): normalize the detail command's HTML fallback branch

The JSON-LD and rendered-HTML branches returned structurally different
records: the fallback emitted raw DD-MM-YYYY page text as datePosted,
free text (including the literal "Loebende") as validThrough, and a
hardcoded null addressLocality. Overview dates now convert to ISO,
Loebende maps to null, and the locality derives from the workplace
address via the same exported extractCity search uses. Review finding
F25 (2026-08-19).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mads LorentzenandClaude Opus 5 committed 2026-08-19 20:53:24 +02:00
1 parent bcba687fbf
commit dab215073e
4 files changed
+46 -7

No files matched your search

@@ -34,7 +34,7 @@ interface ApiSearchResponse {
totalPages: number
}
function toContractDate(value: string | null): string | null {
export function toContractDate(value: string | null): string | null {
const match = value?.match(/^(\d{2})-(\d{2})-(\d{4})$/)
return match ? `${match[3]}-${match[2]}-${match[1]}` : (value ?? null)
}
@@ -43,7 +43,7 @@ function toContractDate(value: string | null): string | null {
// "Lautruphoej 2, 2750 Ballerup" or "2670, Greve". The comma fallback
// requires a non-digit after the comma so a 4-digit street number
// ("Vejlevej 1234, 7100 Vejle") never wins over the real postcode.
function extractCity(address: string | null): string | null {
export function extractCity(address: string | null): string | null {
if (!address) return null
const city =
address.match(/\d{4}\s+(.+)$/)?.[1] ?? address.match(/\d{4}\s*,\s*([^\d,].*)$/)?.[1]