Fix robust project name resolution in backend
Deploy Bürgerwind / deploy (push) Successful in 16s Details

This commit is contained in:
Johannes Baumeister 2026-04-29 21:52:40 +02:00
parent b5c523ab07
commit af8ed45f4d
1 changed files with 3 additions and 3 deletions

View File

@ -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;