Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the same value for range start and end value #291

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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