diff --git a/src/lib/components/automations/AutomationEditor.svelte b/src/lib/components/automations/AutomationEditor.svelte index 4e42626e7b..1f086ac098 100644 --- a/src/lib/components/automations/AutomationEditor.svelte +++ b/src/lib/components/automations/AutomationEditor.svelte @@ -95,7 +95,7 @@ }; const formatSchedule = (rrule: string): string => { - if (rrule.includes('COUNT=1')) { + if (/COUNT=1(?!\d)/.test(rrule)) { const match = rrule.match(/DTSTART:(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})/); if (match) { const d = new Date(`${match[1]}-${match[2]}-${match[3]}T${match[4]}:${match[5]}`); @@ -109,6 +109,9 @@ const parts: Record = {}; rrule + .split(/\s+/) + .filter((line) => !line.toUpperCase().startsWith('DTSTART')) + .join('') .replace('RRULE:', '') .split(';') .forEach((part) => { diff --git a/src/lib/components/automations/ScheduleDropdown.svelte b/src/lib/components/automations/ScheduleDropdown.svelte index 960ca64695..e994109da3 100644 --- a/src/lib/components/automations/ScheduleDropdown.svelte +++ b/src/lib/components/automations/ScheduleDropdown.svelte @@ -106,7 +106,7 @@ export const parseRrule = (s: string) => { // Detect ONCE (COUNT=1 with DTSTART) - if (s.includes('COUNT=1')) { + if (/COUNT=1(?!\d)/.test(s)) { frequency = 'ONCE'; const match = s.match(/DTSTART:(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})/); if (match) { @@ -116,7 +116,10 @@ return; } const parts: Record = {}; - s.replace('RRULE:', '') + s.split(/\s+/) + .filter((line) => !line.toUpperCase().startsWith('DTSTART')) + .join('') + .replace('RRULE:', '') .split(';') .forEach((p) => { const [k, v] = p.split('='); diff --git a/src/routes/(app)/automations/+page.svelte b/src/routes/(app)/automations/+page.svelte index 2b0bfb00e8..0d596091a4 100644 --- a/src/routes/(app)/automations/+page.svelte +++ b/src/routes/(app)/automations/+page.svelte @@ -307,7 +307,7 @@ const formatRRule = (rrule: string): string => { // Detect one-time schedule (ONCE) - if (rrule.includes('COUNT=1')) { + if (/COUNT=1(?!\d)/.test(rrule)) { const match = rrule.match(/DTSTART:(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})/); if (match) { const d = new Date(`${match[1]}-${match[2]}-${match[3]}T${match[4]}:${match[5]}`); @@ -317,6 +317,9 @@ } const parts: Record = {}; rrule + .split(/\s+/) + .filter((line) => !line.toUpperCase().startsWith('DTSTART')) + .join('') .replace('RRULE:', '') .split(';') .forEach((p) => {