Fix issue with new SRF URL pattern
Resolves MS-927 #complete
This commit is contained in:
parent
1594bb2b68
commit
acaeae0cf7
|
|
@ -1,7 +1,12 @@
|
||||||
const YOUTUBE = /^(?:https:\/\/)?(?:www.)?(?:youtube.com\/watch\?v=|youtu.be\/)([a-zA-Z0-9_-]{11})(?:.+)?$/;
|
const YOUTUBE = /^(?:https:\/\/)?(?:www.)?(?:youtube.com\/watch\?v=|youtu.be\/)([a-zA-Z0-9_-]{11})(?:.+)?$/;
|
||||||
const VIMEO = /^(?:https:\/\/)?(?:www.)?vimeo.com\/([a-zA-Z0-9]*)$/;
|
const VIMEO = /^(?:https:\/\/)?(?:www.)?vimeo.com\/([a-zA-Z0-9]*)$/;
|
||||||
// const SRF = /^(?:https:\/\/)?(?:www.)?srf.ch\/(?:[\w/-]*)[?&]id=([\w-]+)(?:[&\w=-]*)$/;
|
/*
|
||||||
const SRF = /^(?:https:\/\/)?(?:www.)?srf.ch\/(?:[\w/-]*)[?&]id=([\w-]+)(?:[&\w=-]*)(?:&?startTime=([\d.]+))?/;
|
* Handles URLs like
|
||||||
|
* - https://www.srf.ch/play/tv/popupvideoplayer?id=6db02b8b-975c-4e3e-8260-f1e6eca1d8ed
|
||||||
|
* - https://www.srf.ch/play/tv/we-myself--why/video/nein-sagen-so-klappt-es?urn=urn:srf:video:6db02b8b-975c-4e3e-8260-f1e6eca1d8e
|
||||||
|
*/
|
||||||
|
const SRF =
|
||||||
|
/^(?:https:\/\/)?(?:www.)?srf.ch\/(?:[\w/-]*)[?&](?:id=|urn=urn:srf:video:)([\w-]+)(?:[&\w=-]*)(?:&?startTime=([\d.]+))?/;
|
||||||
|
|
||||||
export function isYoutubeUrl(url: string) {
|
export function isYoutubeUrl(url: string) {
|
||||||
return YOUTUBE.test(url);
|
return YOUTUBE.test(url);
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,31 @@ import { getVideoId } from '../../src/helpers/video';
|
||||||
import { mount } from '@vue/test-utils';
|
import { mount } from '@vue/test-utils';
|
||||||
import SrfEmbed from '@/components/videos/SrfEmbed.vue';
|
import SrfEmbed from '@/components/videos/SrfEmbed.vue';
|
||||||
|
|
||||||
const url = 'https://www.srf.ch/play/tv/popupvideoplayer?id=6db02b8b-975c-4e3e-8260-f1e6eca1d8ed';
|
describe('Legacy SRF Video Embed', () => {
|
||||||
const embedUrl =
|
const videoId = '6db02b8b-975c-4e3e-8260-f1e6eca1d8ed';
|
||||||
'https://www.srf.ch/play/embed?urn=urn:srf:video:6db02b8b-975c-4e3e-8260-f1e6eca1d8ed&subdivisions=false';
|
const url = `https://www.srf.ch/play/tv/popupvideoplayer?id=${videoId}`;
|
||||||
describe('SRF Video Embed', () => {
|
const embedUrl = `https://www.srf.ch/play/embed?urn=urn:srf:video:${videoId}&subdivisions=false`;
|
||||||
it('should return the correct embed url', () => {
|
it('should return the correct embed url', () => {
|
||||||
const videoId = getVideoId(url);
|
const extractedId = getVideoId(url);
|
||||||
const embedId = '6db02b8b-975c-4e3e-8260-f1e6eca1d8ed';
|
expect(extractedId).toBe(videoId);
|
||||||
expect(videoId).toBe(embedId);
|
});
|
||||||
|
it('should construct the correct iframe', () => {
|
||||||
|
const props = {
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
const wrapper = mount(SrfEmbed, {
|
||||||
|
props,
|
||||||
|
});
|
||||||
|
expect(wrapper.attributes('src')).toBe(embedUrl);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('New SRF Video Embed', () => {
|
||||||
|
const videoId = '6db02b8b-975c-4e3e-8260-f1e6eca1d8ed';
|
||||||
|
const url = `https://www.srf.ch/play/tv/we-myself--why/video/nein-sagen-so-klappt-es?urn=urn:srf:video:${videoId}`;
|
||||||
|
const embedUrl = `https://www.srf.ch/play/embed?urn=urn:srf:video:${videoId}&subdivisions=false`;
|
||||||
|
it('should return the correct embed url', () => {
|
||||||
|
const extractedId = getVideoId(embedUrl);
|
||||||
|
expect(extractedId).toBe(videoId);
|
||||||
});
|
});
|
||||||
it('should construct the correct iframe', () => {
|
it('should construct the correct iframe', () => {
|
||||||
const props = {
|
const props = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue