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

fix: infinite loops in iter when interval is undefined #494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/parseoptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export function parseOptions (options: Partial<Options>) {

if (isPresent(opts.byeaster)) opts.freq = RRule.YEARLY

if (!isPresent(opts.interval)) opts.interval = 1

if (!(isPresent(opts.freq) && RRule.FREQUENCIES[opts.freq])) {
throw new Error(`Invalid frequency: ${opts.freq} ${options.freq}`)
}
Expand Down
7 changes: 7 additions & 0 deletions test/parseoptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ describe('byweekday', () => {
expect(options.parsedOptions.byweekday).to.eql([1, 2])
})
})

describe('interval', () => {
it('assigns interval to 1 when not present', () => {
const options = parseOptions({interval: undefined})
expect(options.parsedOptions.interval).to.eql(1)
})
})