Skip to content

Standard matching VTT definition #10

@gmkll

Description

@gmkll

Although you mention, that you want to comply with JWPlayers VTT definition only, the official one https://www.w3.org/TR/webvtt1/ states, that Web Vtt timing has before and after --> one or more U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characters.

You already have a construct, which has an optional whitespace in ( ?--> ?), but this would allow even none space (e.g. 00:00:00.000-->00:00:0, which is not correct/allowed (context is in processVtt function matching vttDef variable:
vttDef.match(/([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?( ?--> ?)([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?[\r\n]{1}.*/gi)).

I suggest changing this part to ( +?--> +?) (+ = one or more - ? becomes non greedy quantifier) or at least fix it by adding one extra optional space ( ?--> ?), that is the regex becomes:
vttDef.match(/([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?( +?--> +?)([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?[\r\n]{1}.*/gi).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions