Skip to content
Open
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
5 changes: 2 additions & 3 deletions src/utils/webvtt-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export function parseWebVTT(
// Convert byteArray into string, replacing any somewhat exotic linefeeds with "\n", then split on that character.
// Uint8Array.prototype.reduce is not implemented in IE11
const vttLines = utf8ArrayToStr(new Uint8Array(vttByteArray))
.trim()
.replace(LINEBREAKS, '\n')
.split('\n');
const cues: VTTCue[] = [];
Expand Down Expand Up @@ -150,14 +149,14 @@ export function parseWebVTT(
cue.endTime = Math.max(startTime + duration, 0);

//trim trailing webvtt block whitespaces
const text = cue.text.trim();
const text = cue.text;

// Fix encoding of special characters
cue.text = decodeURIComponent(encodeURIComponent(text));

// If the cue was not assigned an id from the VTT file (line above the content), create one.
if (!cue.id) {
cue.id = generateCueId(cue.startTime, cue.endTime, text);
cue.id = generateCueId(cue.startTime, cue.endTime, text.trim());
}

if (cue.endTime > 0) {
Expand Down