Skip to content

Commit

Permalink
Support all timecode formats for YouTube preview (#4957) (#5032)
Browse files Browse the repository at this point in the history
  • Loading branch information
AymaneKhouaji authored and jwilander committed Feb 7, 2017
1 parent 233f43e commit 17d1ed1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions webapp/components/youtube_video.jsx
Expand Up @@ -57,16 +57,16 @@ export default class YoutubeVideo extends React.Component {
}

handleYoutubeTime(link) {
const timeRegex = /[\\?&]t=([0-9hms]+)/;
const timeRegex = /[\\?&]t=([0-9]+h)?([0-9]+m)?([0-9]+s?)/;

const time = link.match(timeRegex);
if (!time || !time[1]) {
if (!time || !time[0]) {
return '';
}

const hours = time[1].match(/([0-9]+)h/);
const minutes = time[1].match(/([0-9]+)m/);
const seconds = time[1].match(/([0-9]+)s/);
const hours = time[1] ? time[1].match(/([0-9]+)h/) : null;
const minutes = time[2] ? time[2].match(/([0-9]+)m/) : null;
const seconds = time[3] ? time[3].match(/([0-9]+)s?/) : null;

let ticks = 0;

Expand Down

0 comments on commit 17d1ed1

Please sign in to comment.