Skip to content

Commit

Permalink
allowing empty comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetman authored and sdroege committed Dec 4, 2023
1 parent b9cf88b commit d8e0283
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ enum MasterPlaylistTag {
SessionKey(SessionKey),
Start(Start),
IndependentSegments,
Comment(String),
Comment(Option<String>),
Uri(String),
Unknown(ExtTag),
}
Expand Down Expand Up @@ -487,7 +487,7 @@ enum SegmentTag {
ProgramDateTime(chrono::DateTime<chrono::FixedOffset>),
DateRange(DateRange),
Unknown(ExtTag),
Comment(String),
Comment(Option<String>),
Uri(String),
}

Expand Down Expand Up @@ -609,10 +609,10 @@ fn ext_tag(i: &[u8]) -> IResult<&[u8], ExtTag> {
)(i)
}

fn comment_tag(i: &[u8]) -> IResult<&[u8], String> {
fn comment_tag(i: &[u8]) -> IResult<&[u8], Option<String>> {
map(
pair(
preceded(char('#'), map_res(is_not("\r\n"), from_utf8_slice)),
preceded(char('#'), opt(map_res(is_not("\r\n"), from_utf8_slice))),
take(1usize),
),
|(text, _)| text,
Expand Down Expand Up @@ -929,7 +929,7 @@ mod tests {
fn comment() {
assert_eq!(
comment_tag(b"#Hello\nxxx"),
Result::Ok(("xxx".as_bytes(), "Hello".to_string()))
Result::Ok(("xxx".as_bytes(), Some("Hello".to_string())))
);
}

Expand Down

0 comments on commit d8e0283

Please sign in to comment.