refactor: review changes to use existing youtube function
This commit is contained in:
committed by
Ken Clary
parent
b4fb88c73c
commit
475c32463a
@@ -1,13 +1,8 @@
|
||||
import messages from '../messages';
|
||||
|
||||
// https://stackoverflow.com/a/28735961/479084
|
||||
const youtubeRegex = /^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
|
||||
function isYoutubeUrl(url) {
|
||||
return url.match(youtubeRegex) !== null;
|
||||
}
|
||||
import { parseYoutubeId } from '../../../../../../data/services/cms/api';
|
||||
|
||||
function getVideoType(videoSource) {
|
||||
if (isYoutubeUrl(videoSource)) {
|
||||
if (parseYoutubeId(videoSource) !== null) {
|
||||
return messages.videoTypeYoutube;
|
||||
}
|
||||
return messages.videoTypeOther;
|
||||
|
||||
@@ -68,7 +68,7 @@ export const messages = {
|
||||
},
|
||||
videoTypeYoutube: {
|
||||
id: 'authoring.videoeditor.videotype.youtube',
|
||||
defaultMessage: 'Youtube video',
|
||||
defaultMessage: 'YouTube video',
|
||||
description: 'Shown on the preview card if the video is from youtube.com.',
|
||||
},
|
||||
videoTypeOther: {
|
||||
|
||||
Reference in New Issue
Block a user