Merge pull request #52 from bclwhitaker/bugfix/stripCarriageReturns
Strip carriage returns when parsing lines in manifests.
Showing
2 changed files
with
21 additions
and
0 deletions
... | @@ -117,6 +117,10 @@ | ... | @@ -117,6 +117,10 @@ |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | 119 | ||
120 | //strip off any carriage returns here so the regex matching | ||
121 | //doesn't have to account for them. | ||
122 | line = line.replace('\r',''); | ||
123 | |||
120 | // Tags | 124 | // Tags |
121 | match = /^#EXTM3U/.exec(line); | 125 | match = /^#EXTM3U/.exec(line); |
122 | if (match) { | 126 | if (match) { | ... | ... |
... | @@ -206,6 +206,23 @@ | ... | @@ -206,6 +206,23 @@ |
206 | manifest.substring(manifest.indexOf(',') + 1, manifest.length - 1), | 206 | manifest.substring(manifest.indexOf(',') + 1, manifest.length - 1), |
207 | 'the title is parsed'); | 207 | 'the title is parsed'); |
208 | }); | 208 | }); |
209 | test('parses #EXTINF tags with carriage returns', function() { | ||
210 | var | ||
211 | manifest = '#EXTINF:13,Does anyone really use the title attribute?\r\n', | ||
212 | element; | ||
213 | parseStream.on('data', function(elem) { | ||
214 | element = elem; | ||
215 | }); | ||
216 | lineStream.push(manifest); | ||
217 | |||
218 | ok(element, 'an event was triggered'); | ||
219 | strictEqual(element.type, 'tag', 'the line type is tag'); | ||
220 | strictEqual(element.tagType, 'inf', 'the tag type is inf'); | ||
221 | strictEqual(element.duration, 13, 'the duration is parsed'); | ||
222 | strictEqual(element.title, | ||
223 | manifest.substring(manifest.indexOf(',') + 1, manifest.length - 2), | ||
224 | 'the title is parsed'); | ||
225 | }); | ||
209 | 226 | ||
210 | // #EXT-X-TARGETDURATION | 227 | // #EXT-X-TARGETDURATION |
211 | test('parses minimal #EXT-X-TARGETDURATION tags', function() { | 228 | test('parses minimal #EXT-X-TARGETDURATION tags', function() { | ... | ... |
-
Please register or sign in to post a comment