Skip to content

Commit 61203a4

Browse files
authored
Merge pull request #38 from customgento/DEV-1111-fix-blocked-video-styles
Allow local videos, DEV-1111
2 parents fe3da1f + 5c2cb3a commit 61203a4

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

view/frontend/web/js/slide-widget-mixin.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,30 @@ define([
88
'use strict';
99

1010
return function (originalWidget) {
11+
function isSupportedVideoPlatform(url) {
12+
if (!url) {
13+
return false;
14+
}
15+
16+
// Regex patterns for supported video platforms
17+
const youtubePattern = /^https?:\/\/(www\.)?(youtube\.com|youtu\.be)\//i;
18+
const youtubeNocookiePattern = /^https?:\/\/(www\.)?youtube-nocookie\.com\//i;
19+
const vimeoPattern = /^https?:\/\/(www\.)?(vimeo\.com|player\.vimeo\.com)\//i;
20+
21+
return youtubePattern.test(url) ||
22+
youtubeNocookiePattern.test(url) ||
23+
vimeoPattern.test(url);
24+
}
25+
1126
return function (config, element) {
1227
const videoElement = element[0].querySelector('[data-background-type=video]');
1328
const blockVideoConsentConfig = window.cookiebotConfig && window.cookiebotConfig.blockVideosUntilConsent;
29+
const videoSrc = videoElement.getAttribute('data-video-src');
30+
const cookieblockSrc = videoElement.getAttribute('data-cookieblock-src');
31+
const src = videoSrc || cookieblockSrc;
1432
let previousStatus = '';
15-
if (!videoElement || !blockVideoConsentConfig) {
33+
34+
if (!videoElement || !blockVideoConsentConfig || !isSupportedVideoPlatform(src)) {
1635
originalWidget(config, element);
1736
return;
1837
}
@@ -23,7 +42,7 @@ define([
2342
addEventListener('CookiebotOnLoad', sliderVideoBlocker);
2443

2544
function sliderVideoBlocker() {
26-
if (previousStatus === 'blocked' && !Cookiebot?.consent?.marketing) {
45+
if (previousStatus === 'blocked' && (!Cookiebot?.consent?.marketing)) {
2746
return;
2847
}
2948

0 commit comments

Comments
 (0)