Refactor text normalization in worshipController.js: Rename normalizeText to normalizeForMatch for clarity and update all references to ensure consistent text processing across various functions, enhancing code readability and maintainability.
All checks were successful
Deploy miriamgemeinde / deploy (push) Successful in 7s

This commit is contained in:
Torsten Schulz (local)
2026-04-29 19:04:56 +02:00
parent 1182426cda
commit afa9b4a6b5

View File

@@ -1825,7 +1825,7 @@ function getSection(lines, startPredicate, endPredicates = []) {
return lines.slice(start, end);
}
function normalizeText(input) {
function normalizeForMatch(input) {
return String(input || '')
.toLowerCase()
.replace(/ä/g, 'ae')
@@ -1837,8 +1837,8 @@ function normalizeText(input) {
}
function isHeading(line, heading) {
const normalizedLine = normalizeText(line).replace(/[:\-]\s*$/g, '');
const normalizedHeading = normalizeText(heading).replace(/[:\-]\s*$/g, '');
const normalizedLine = normalizeForMatch(line).replace(/[:\-]\s*$/g, '');
const normalizedHeading = normalizeForMatch(heading).replace(/[:\-]\s*$/g, '');
return (
normalizedLine === normalizedHeading ||
normalizedLine.startsWith(`${normalizedHeading} `) ||
@@ -1902,7 +1902,7 @@ function buildDetailedItems(lines) {
};
const expandedLines = lines.flatMap(splitForYouthAnchors);
const isHardSectionBoundary = (line) => {
const n = normalizeText(line);
const n = normalizeForMatch(line);
if (!n) return false;
return (
n.startsWith('besondere gottesdienste und veranstaltungen') ||
@@ -1987,7 +1987,7 @@ function buildDetailedItems(lines) {
}
function isNoiseLine(line) {
const n = normalizeText(line);
const n = normalizeForMatch(line);
return (
n.includes('impressum') ||
n.includes('redaktionsschluss') ||
@@ -2064,7 +2064,7 @@ function extractRegularTermineDetails(lines) {
const seen = new Set();
const isAnchorLine = (line) => anchors.some((r) => r.test(line));
const isSubHeadingLike = (line) => {
const t = normalizeText(line);
const t = normalizeForMatch(line);
return (
/^kinder und jugendliche$/.test(t) ||
/^kinder und jugend$/.test(t) ||
@@ -2120,7 +2120,7 @@ function isLikelyDayNameLine(line) {
if (!line) return false;
if (hasDateOrTime(line)) return false;
if (looksLikeHeading(line)) return false;
const t = normalizeText(line);
const t = normalizeForMatch(line);
return (
/advent|trinitatis|epiphanias|ostern|pfingsten|sonntag|montag|dienstag|mittwoch|donnerstag|freitag|samstag/.test(t) &&
t.length < 80
@@ -2229,7 +2229,7 @@ function extractWorshipBlocks(lines) {
}
function buildEventSignature(line) {
const text = normalizeText(line);
const text = normalizeForMatch(line);
const anchorPatterns = [
/kinderkirche/,
/kigosabo|kindergottesdienst/,