Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Trim whitespace in playlist #282

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 3 additions & 0 deletions src/m3u8/m3u8-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
*/
ParseStream.prototype.push = function(line) {
var match, event;

//strip whitespace
line = line.replace(/^\s+|\s+$/g, '');
if (line.length === 0) {
// ignore empty lines
return;
Expand Down
25 changes: 25 additions & 0 deletions test/manifest/whiteSpace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"allowCache": true,
"mediaSequence": 0,
"playlistType": "VOD",
"segments": [
{
"duration": 10,
"uri": "http://example.com/00001.ts"
},
{
"duration": 10,
"uri": "https://example.com/00002.ts"
},
{
"duration": 10,
"uri": "//example.com/00003.ts"
},
{
"duration": 10,
"uri": "http://example.com/00004.ts"
}
],
"targetDuration": 10,
"endList": true
}
14 changes: 14 additions & 0 deletions test/manifest/whiteSpace.m3u8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:10

#EXTINF:10,
http://example.com/00001.ts
#EXTINF:10,
https://example.com/00002.ts
#EXTINF:10,
//example.com/00003.ts
#EXTINF:10,
http://example.com/00004.ts
#ZEN-TOTAL-DURATION:57.9911
#EXT-X-ENDLIST