diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/hooks.js b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/hooks.js index ac2a03fc3..1365df536 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/hooks.js +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoPreviewWidget/hooks.js @@ -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; diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/messages.js b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/messages.js index 63b6636ba..fe8b15f4f 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/messages.js +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/messages.js @@ -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: {