From af8ed45f4d629ec0a43d794e279b010135992427 Mon Sep 17 00:00:00 2001 From: Johannes Baumeister Date: Wed, 29 Apr 2026 21:52:40 +0200 Subject: [PATCH] Fix robust project name resolution in backend --- server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 1b61a5d..a8e4249 100644 --- a/server.js +++ b/server.js @@ -121,11 +121,11 @@ async function resolveProjectId(client, input) { const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; if (uuidRegex.test(input)) return input; - // Normalisierte Suche (Kleinschreibung, Bindestriche zu Unterstrichen) - const normalized = input.toLowerCase().replace(/-/g, '_'); + // Normalisierte Suche (Kleinschreibung, alle Bindestriche und Unterstriche entfernen) + const normalized = input.toLowerCase().replace(/[-_]/g, ''); const res = await client.query( - 'SELECT id FROM geodaten.projekte WHERE LOWER(name) = $1 OR LOWER(REPLACE(name, \'-\', \'_\')) = $1', + 'SELECT id FROM geodaten.projekte WHERE LOWER(REPLACE(REPLACE(name, \'-\', \'\'), \'_\', \'\')) = $1', [normalized] ); return res.rows.length > 0 ? res.rows[0].id : null;