From f4b47a9275d597f7f3eb47dbc89603859be166f9 Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Thu, 4 Apr 2019 08:51:20 +0300 Subject: fixed setting youtube host for non-https case --- src/js/plugins/youtube.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index d5972c80..cac1a90f 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -34,6 +34,22 @@ function assurePlaybackState(play) { } } +function useHttp() { + return !window.location.href.includes('https://'); +} + +function getYoutubeHost(config) { + let host; + + if (config.noCookie) { + host = 'https://www.youtube-nocookie.com'; + } else { + host = useHttp() ? 'http://www.youtube.com' : undefined; + } + + return host; +} + const youtube = { setup() { // Add embed class for responsive @@ -151,7 +167,7 @@ const youtube = { // https://developers.google.com/youtube/iframe_api_reference player.embed = new window.YT.Player(id, { videoId, - host: config.noCookie ? 'https://www.youtube-nocookie.com' : undefined, + host: getYoutubeHost(config), playerVars: extend( {}, { -- cgit v1.2.3 From c22f5c4b39ba545508392343fc0ffcfa4775dfdb Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Thu, 4 Apr 2019 08:56:46 +0300 Subject: code cleanup --- src/js/plugins/youtube.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index cac1a90f..1f827776 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -34,20 +34,12 @@ function assurePlaybackState(play) { } } -function useHttp() { - return !window.location.href.includes('https://'); -} - function getYoutubeHost(config) { - let host; - if (config.noCookie) { - host = 'https://www.youtube-nocookie.com'; - } else { - host = useHttp() ? 'http://www.youtube.com' : undefined; + return 'https://www.youtube-nocookie.com'; } - return host; + return `${window.location.protocol}//www.youtube.com`; } const youtube = { -- cgit v1.2.3 From 21539be3f2b01a549c920ee683c2121f53929d96 Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Thu, 4 Apr 2019 09:32:38 +0300 Subject: code cleanup --- src/js/plugins/youtube.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/js/plugins/youtube.js b/src/js/plugins/youtube.js index 1f827776..9c447f7d 100644 --- a/src/js/plugins/youtube.js +++ b/src/js/plugins/youtube.js @@ -34,7 +34,7 @@ function assurePlaybackState(play) { } } -function getYoutubeHost(config) { +function getHost(config) { if (config.noCookie) { return 'https://www.youtube-nocookie.com'; } @@ -159,7 +159,7 @@ const youtube = { // https://developers.google.com/youtube/iframe_api_reference player.embed = new window.YT.Player(id, { videoId, - host: getYoutubeHost(config), + host: getHost(config), playerVars: extend( {}, { -- cgit v1.2.3