Skip to content

Commit

Permalink
Allow the same value for range start and end value (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisiirak committed Nov 9, 2022
1 parent fefd0a2 commit 7d8aad6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
' expected range ' +
constraints.min + '-' + constraints.max
);
} else if (min >= max) {
} else if (min > max) {
throw new Error('Invalid range: ' + val);
}

Expand All @@ -343,7 +343,6 @@ CronExpression._parseField = function _parseField (field, value, constraints) {
repeatIndex++;
}
}

return stack;
}

Expand Down
11 changes: 11 additions & 0 deletions test/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ test('incremental range test with iterator', function(t) {
t.end();
});

test('range with the same start and end value', function(t) {
try {
var interval = CronExpression.parse('*/10 2-2 * * *');
t.ok(interval, 'Interval parsed');
} catch (err) {
t.error(err, 'Interval parse error');
}

t.end();
});

test('predefined expression', function(t) {
try {
var interval = CronExpression.parse('@yearly');
Expand Down

0 comments on commit 7d8aad6

Please sign in to comment.