Support all timecode formats for YouTube preview (#4957) (#5032)

Этот коммит содержится в:
AymaneKhouaji
2017-02-07 07:25:08 +01:00
коммит произвёл Joram Wilander
родитель 233f43e47f
Коммит 17d1ed114c

Просмотреть файл

@@ -57,16 +57,16 @@ export default class YoutubeVideo extends React.Component {
} }
handleYoutubeTime(link) { handleYoutubeTime(link) {
const timeRegex = /[\\?&]t=([0-9hms]+)/; const timeRegex = /[\\?&]t=([0-9]+h)?([0-9]+m)?([0-9]+s?)/;
const time = link.match(timeRegex); const time = link.match(timeRegex);
if (!time || !time[1]) { if (!time || !time[0]) {
return ''; return '';
} }
const hours = time[1].match(/([0-9]+)h/); const hours = time[1] ? time[1].match(/([0-9]+)h/) : null;
const minutes = time[1].match(/([0-9]+)m/); const minutes = time[2] ? time[2].match(/([0-9]+)m/) : null;
const seconds = time[1].match(/([0-9]+)s/); const seconds = time[3] ? time[3].match(/([0-9]+)s?/) : null;
let ticks = 0; let ticks = 0;