1
1
Fork 0
mirror of https://github.com/rutgersc/m3u8-rs.git synced 2025-03-13 09:42:39 +00:00
This commit is contained in:
Ritvars 2024-12-24 11:10:39 +00:00 committed by GitHub
commit 32548302d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -526,11 +526,10 @@ fn duration_title_tag(i: &[u8]) -> IResult<&[u8], (f32, Option<String>)> {
tuple((
float,
opt(char(',')),
opt(map_res(is_not("\r\n,"), from_utf8_slice)),
opt(map_res(is_not("\r\n"), from_utf8_slice)),
take(1usize),
opt(char(',')),
)),
|(duration, _, title, _, _)| (duration, title),
|(duration, _, title, _)| (duration, title),
)(i)
}
@ -995,6 +994,25 @@ mod tests {
);
}
#[test]
fn parse_duration_title_with_commas() {
assert_eq!(
duration_title_tag(b"2.002,title,with,commas\nrest"),
Result::Ok((
"rest".as_bytes(),
(2.002f32, Some("title,with,commas".to_string()))
))
);
}
#[test]
fn parse_duration_title_without_title() {
assert_eq!(
duration_title_tag(b"2.002\nrest"),
Result::Ok(("rest".as_bytes(), (2.002f32, None)))
);
}
#[test]
fn incomplete_manifest() {
assert!(!is_master_playlist(