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(parser): ensure dateRange uses startDate for condition #187

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,12 @@ export default class Parser extends Stream {
message: 'EXT-X-DATERANGE with an END-ON-NEXT=YES attribute must not contain DURATION or END-DATE attributes'
});
}
if (dateRange.duration && dateRange.endDate) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer to the discussion in #186 , but I think we may want to do something like

if (dateRange.startDate && dateRange.duration && dateRange.endDate)

instead.
Perhaps with a warning and early return if the startDate + duration !== endDate to ensure we don't create any bad dateRanges.

Copy link
Author

@pmendozav pmendozav Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrums86

I updated the constraint to include dateRange.endDate, ensuring that dateRanges[index].endDate is created according to the specification and that a valid startDate is present. This should be sufficient to prevent the creation of invalid dateRanges, as you mentioned.

Additionally, I added a warning.

if (dateRange.duration && dateRange.endDate && !dateRange.startDate) {
this.trigger('warn', {
message: 'EXT-X-DATERANGE with DURATION and END-DATE attributes must contain START-DATE attribute'
});
}
if (dateRange.duration && dateRange.endDate && dateRange.startDate) {
const startDate = dateRange.startDate;
const newDateInSeconds = startDate.getTime() + (dateRange.duration * 1000);

Expand Down
Loading