From c4cba4c591c16899073264ec95b478548bb7841b Mon Sep 17 00:00:00 2001 From: Turo Mikkonen Date: Tue, 11 Apr 2023 13:18:37 +0300 Subject: [PATCH] fix: don't trim line breaks --- src/utils/webvtt-parser.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/utils/webvtt-parser.ts b/src/utils/webvtt-parser.ts index af50e4ab119..72e7a9d1c61 100644 --- a/src/utils/webvtt-parser.ts +++ b/src/utils/webvtt-parser.ts @@ -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[] = []; @@ -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) {