Accept 5-digit dienst numbers and normalize lookup type

This commit is contained in:
Eddy de Vink 2026-09-14 15:06:14 +02:00
commit c97d662856
3 changed files with 4 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ node_modules/
.env .env
AGENTS.md AGENTS.md
diensten/ diensten/
diensten_*/

View file

@ -33,7 +33,7 @@ function loadDiensten() {
function findDienst(dienstnummer) { function findDienst(dienstnummer) {
const diensten = loadDiensten() const diensten = loadDiensten()
return diensten.find(d => d.dienstnummer === dienstnummer) || null return diensten.find(d => String(d.dienstnummer) === dienstnummer) || null
} }
function getPngFilePaths(dienst) { function getPngFilePaths(dienst) {

View file

@ -6,7 +6,7 @@ const { increment: incrementDaily } = require('./dailyStats')
const ALLOWED_GROUP = process.env.ALLOWED_GROUP const ALLOWED_GROUP = process.env.ALLOWED_GROUP
function extractDienstnummer(body) { function extractDienstnummer(body) {
const match = body.match(/^\s*(\d{4})\s*$/) const match = body.match(/^\s*(\d{4,5})\s*$/)
return match ? match[1] : null return match ? match[1] : null
} }
@ -66,4 +66,4 @@ async function handleWebhook(payload) {
} }
} }
module.exports = { handleWebhook } module.exports = { handleWebhook, extractDienstnummer }