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

Parser doesn't respect timestamps with single digit hours #8

Closed
alecananian opened this issue Dec 2, 2016 · 3 comments
Closed

Parser doesn't respect timestamps with single digit hours #8

alecananian opened this issue Dec 2, 2016 · 3 comments

Comments

@alecananian
Copy link

The regular expression supplied for matching a WebVTT timestamp does not allow for a timestamp that denotes the hour number with a single digit:

Regular Expression

const TIMESTAMP_REGEXP = /([0-9]{2})?:?([0-9]{2}):([0-9]{2}\.[0-9]{3})/;

Example timestamps

59:58.000 --> 59:59.000
<b>(GASPS) Hunter?</b>

1:00:00.000 --> 1:00:01.000
<b>You're fired!</b>

However according to the WebVTT spec and its description of how to parse a timestamp, a parser should allow for this case:

If string is not exactly two characters in length, or if value1 is greater than 59, let most significant units be hours.

The solution would be to update the regular expression to allow for 1 or 2 digits in the hours slot:

const TIMESTAMP_REGEXP = /([0-9]{1,2})?:?([0-9]{2}):([0-9]{2}\.[0-9]{3})/;
@alecananian
Copy link
Author

Sorry, I see this has already been fixed. It looks like the latest version was never pushed to npm, though. Closing this and will use the latest git commits for my project.

@osk
Copy link
Owner

osk commented Dec 5, 2016

@alecananian no problem, but it is truly an issue since the package needs updating on NPM, I'm on it

@osk osk reopened this Dec 5, 2016
@osk
Copy link
Owner

osk commented Dec 5, 2016

Updated! Thanks for the report

@osk osk closed this as completed Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants