refactor: guard against potential undefined cron expression

This commit is contained in:
Nicolas Meienberger 2025-12-22 19:46:47 +01:00
parent be8df3c90d
commit 6af9c5a7b8
2 changed files with 5 additions and 1 deletions

View file

@ -83,7 +83,7 @@ const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalFormValu
return undefined;
}
const cronValues = cronToFormValues(schedule.cronExpression);
const cronValues = cronToFormValues(schedule.cronExpression ?? "0 * * * *");
const patterns = schedule.includePatterns || [];
const isGlobPattern = (p: string) => /[*?[\]]/.test(p);

View file

@ -77,6 +77,10 @@ const matchers: Matcher[] = [
];
export const cronToFormValues = (cronExpression: string): CronFormValues => {
if (!cronExpression) {
return { frequency: "hourly" };
}
const normalized = cronExpression.trim().replace(/\s+/g, " ");
const parts = normalized.split(" ");