feat(ScheduleView): improve club name normalization for match home detection
All checks were successful
Deploy tt-tagebuch / deploy (push) Successful in 1m2s

This commit is contained in:
Torsten Schulz (local)
2026-09-30 11:54:19 +02:00
parent 937a83ae8b
commit 3c9a7d2cee

View File

@@ -1314,17 +1314,29 @@ export default {
},
isOurClubPlayingHome(match) {
const club = (this.currentClubName || '').toString().trim().toLowerCase();
const normalizeClubName = (name) => String(name || '')
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase()
// click-TT führt bei manchen Vereinen eine Jahreszahl, die im
// hinterlegten Vereinsnamen nicht enthalten ist (z. B.
// "TSV Bonames" / "TSV 1875 Bonames (J15)").
.replace(/\b\d+\b/g, ' ')
.replace(/[^\p{L}]+/gu, ' ')
.replace(/\s+/g, ' ')
.trim();
const club = normalizeClubName(this.currentClubName);
if (!club || !match) return false;
const homeName = (match.homeTeam?.name || '').toString().toLowerCase();
const guestName = (match.guestTeam?.name || '').toString().toLowerCase();
const homeHas = homeName.includes(club);
const guestHas = guestName.includes(club);
const homeName = normalizeClubName(match.homeTeam?.name);
const guestName = normalizeClubName(match.guestTeam?.name);
const belongsToClub = (teamName) => teamName === club || teamName.startsWith(`${club} `);
const homeHas = belongsToClub(homeName);
const guestHas = belongsToClub(guestName);
if (homeHas && guestHas) return true; // both teams from our club -> treat as home
if (homeHas) return true;
if (guestHas) return false;
// Fallback: if neither includes club name, prefer original startsWith heuristic
return homeName.startsWith(this.currentClubName || '') || false;
return false;
},
// Dialog Helper Methods