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;