refactor: guard against potential undefined cron expression
This commit is contained in:
parent
be8df3c90d
commit
6af9c5a7b8
2 changed files with 5 additions and 1 deletions
|
|
@ -83,7 +83,7 @@ const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalFormValu
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cronValues = cronToFormValues(schedule.cronExpression);
|
const cronValues = cronToFormValues(schedule.cronExpression ?? "0 * * * *");
|
||||||
|
|
||||||
const patterns = schedule.includePatterns || [];
|
const patterns = schedule.includePatterns || [];
|
||||||
const isGlobPattern = (p: string) => /[*?[\]]/.test(p);
|
const isGlobPattern = (p: string) => /[*?[\]]/.test(p);
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@ const matchers: Matcher[] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
export const cronToFormValues = (cronExpression: string): CronFormValues => {
|
export const cronToFormValues = (cronExpression: string): CronFormValues => {
|
||||||
|
if (!cronExpression) {
|
||||||
|
return { frequency: "hourly" };
|
||||||
|
}
|
||||||
|
|
||||||
const normalized = cronExpression.trim().replace(/\s+/g, " ");
|
const normalized = cronExpression.trim().replace(/\s+/g, " ");
|
||||||
const parts = normalized.split(" ");
|
const parts = normalized.split(" ");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue