Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't trim line breaks #5380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/utils/webvtt-parser.ts
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