fix: strip 'Chapter N - N: ' prefix from chapter titles in content menu
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

This commit is contained in:
Admin
2026-03-02 12:55:08 +05:00
parent 2546a5774e
commit da3370ba9b

View File

@@ -281,6 +281,11 @@ func SplitChapterTitle(raw string) (title, date string) {
}
}
// Strip "Chapter N - N: " prefix (novelfire double-number format).
// Also handles "Chapter N: " (single number) and "Chapter N - Title" without colon.
chNumRe := regexp.MustCompile(`(?i)^chapter\s+\d+(?:\s*-\s*\d+)?\s*:\s*`)
raw = strings.TrimSpace(chNumRe.ReplaceAllString(raw, ""))
// Match a trailing relative date: "<n> <unit>[s] ago"
dateRe := regexp.MustCompile(`\s*(\d+\s+(?:second|minute|hour|day|week|month|year)s?\s+ago)\s*$`)
if m := dateRe.FindStringSubmatchIndex(raw); m != nil {