diff --git a/actions-workflow-parser/src/model/converter/cron.test.ts b/actions-workflow-parser/src/model/converter/cron.test.ts index 533350e..99fa09a 100644 --- a/actions-workflow-parser/src/model/converter/cron.test.ts +++ b/actions-workflow-parser/src/model/converter/cron.test.ts @@ -37,8 +37,8 @@ describe("isValidCron", () => { "0 1/ * * *", "0 ,1 * * *", "0 1, * * *", - "0 -- * * *", - "0 // * * *", + "0 5--5 * * *", + "0 *//5 * * *", "0 ,, * * *", "0 ** * * *", "0 0 * * BUN", @@ -49,6 +49,7 @@ describe("isValidCron", () => { "0 2/4-5 * * *", "0 2-4-6 * * *", "0 2/4/6 * * *", + "0 2/4/6 * * *", ] for (const cron of invalid) { diff --git a/actions-workflow-parser/src/model/converter/cron.ts b/actions-workflow-parser/src/model/converter/cron.ts index 6875928..911494d 100644 --- a/actions-workflow-parser/src/model/converter/cron.ts +++ b/actions-workflow-parser/src/model/converter/cron.ts @@ -67,10 +67,7 @@ function validateRange( if (!allowSeparators) { return false } - // Allow separators - return value.split(",").every((v) => { - v && validateRange(v, range) - }) + return value.split(",").every((v) => v && validateRange(v, range)) } if (value.includes("/")) { @@ -79,11 +76,12 @@ function validateRange( } const [start, step, ...rest] = value.split("/") - // Supports */TUE and similar, which needs to be verified with the go cron library const stepNumber = convertToNumber(range, step) if (rest.length > 0 || stepNumber <= 0 || !start || !step) { return false } + + // Separators are only allowed in the part before the `/`, e.g. `1-5/2` return ( validateRange(start, range) && validateRange(step, range, false) )