diff --git a/src/loader/m3u8-parser.js b/src/loader/m3u8-parser.js index 03f900c7de5..750d9130cff 100644 --- a/src/loader/m3u8-parser.js +++ b/src/loader/m3u8-parser.js @@ -25,7 +25,7 @@ const LEVEL_PLAYLIST_REGEX_FAST = new RegExp([ /|#.*/.source // All other non-segment oriented tags will match with all groups empty ].join(''), 'g'); -const LEVEL_PLAYLIST_REGEX_SLOW = /(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)(.*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/; +const LEVEL_PLAYLIST_REGEX_SLOW = /(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/; const MP4_REGEX_SUFFIX = /\.(mp4|m4s|m4v|m4a)$/i; diff --git a/tests/unit/loader/playlist-loader.js b/tests/unit/loader/playlist-loader.js index 0d103268fcb..a42e46b8f65 100644 --- a/tests/unit/loader/playlist-loader.js +++ b/tests/unit/loader/playlist-loader.js @@ -693,4 +693,28 @@ Rollover38803/20160525T064049-01-69844069.ts let result = M3U8Parser.parseLevelPlaylist(level, 'http://video.example.com/disc.m3u8', 0); assert.strictEqual(result.programDateTime, undefined); }); + + it('tests : at end of tag name is used to divide custom tags', () => { + let level = `#EXTM3U +#EXT-X-VERSION:2 +#EXT-X-TARGETDURATION:10 +#EXT-X-MEDIA-SEQUENCE:69844067 +#EXTINF:9.40, +http://dummy.url.com/hls/live/segment/segment_022916_164500865_719926.ts +#EXTINF:9.56, +http://dummy.url.com/hls/live/segment/segment_022916_164500865_719927.ts +#EXT-X-CUSTOM-DATE:2016-05-27T16:34:44Z +#EXT-X-CUSTOM-JSON:{"key":"value"} +#EXT-X-CUSTOM-URI:http://dummy.url.com/hls/moreinfo.json +#EXTINF:10, no desc +http://dummy.url.com/hls/live/segment/segment_022916_164500865_719928.ts + `; + let result = M3U8Parser.parseLevelPlaylist(level, 'http://dummy.url.com/playlist.m3u8', 0); + assert.strictEqual(result.fragments[2].tagList[0][0], 'EXT-X-CUSTOM-DATE'); + assert.strictEqual(result.fragments[2].tagList[0][1], '2016-05-27T16:34:44Z'); + assert.strictEqual(result.fragments[2].tagList[1][0], 'EXT-X-CUSTOM-JSON'); + assert.strictEqual(result.fragments[2].tagList[1][1], '{"key":"value"}'); + assert.strictEqual(result.fragments[2].tagList[2][0], 'EXT-X-CUSTOM-URI'); + assert.strictEqual(result.fragments[2].tagList[2][1], 'http://dummy.url.com/hls/moreinfo.json'); + }); });