From 442156b1cc76aca9b095cf9cb996d9a7c84eef22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 19 May 2024 23:36:57 +0200 Subject: [PATCH] Don't use cookies when embedding youtube videos When embedding a video in our site YouTube stores cookies in the user's computer that aren't necessary to watch the video, so we'd have to make people accept those cookies before letting them watch the video. Using a URL that doesn't use cookies, like mentioned in YouTube Help [1], is easier, though, and respects people's privacy without affecting the user experience. That I've found some references saying that youtube does store cookies once you hit the "play" button even when using the nocookie server [2]. Not sure whether that's an old behavior or I'm doing something wrong, but I don't see this is the case; even after playing the video, cookies aren't stored on my browser. [1] https://support.google.com/youtube/answer/171780#zippy=%2Cturn-on-privacy-enhanced-mode [2] https://www.cnet.com/news/privacy/youtubes-new-nocookie-feature-continues-to-serve-cookies/ --- app/components/shared/embedded_video_component.rb | 2 +- spec/components/shared/embedded_video_component_spec.rb | 2 +- spec/system/proposals_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/components/shared/embedded_video_component.rb b/app/components/shared/embedded_video_component.rb index 117d230f6..2fd8c1950 100644 --- a/app/components/shared/embedded_video_component.rb +++ b/app/components/shared/embedded_video_component.rb @@ -45,7 +45,7 @@ class Shared::EmbeddedVideoComponent < ApplicationComponent if server == "Vimeo" "https://player.vimeo.com/video/" elsif server == "YouTube" - "https://www.youtube.com/embed/" + "https://www.youtube-nocookie.com/embed/" end end diff --git a/spec/components/shared/embedded_video_component_spec.rb b/spec/components/shared/embedded_video_component_spec.rb index 8a0a705a6..b13361db7 100644 --- a/spec/components/shared/embedded_video_component_spec.rb +++ b/spec/components/shared/embedded_video_component_spec.rb @@ -24,7 +24,7 @@ describe Shared::EmbeddedVideoComponent do it "embeds a youtube video for youtube URLs" do allow(record).to receive(:video_url).and_return "http://www.youtube.com/watch?v=a7UFm6ErMPU" - embed_url = "https://www.youtube.com/embed/a7UFm6ErMPU" + embed_url = "https://www.youtube-nocookie.com/embed/a7UFm6ErMPU" render_inline component diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index 5726495ea..3fbcb5b92 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -305,7 +305,7 @@ describe "Proposals" do visit proposal_path(proposal) within "#js-embedded-video" do - expect(page).to have_css "iframe[src='https://www.youtube.com/embed/a7UFm6ErMPU']" + expect(page).to have_css "iframe[src='https://www.youtube-nocookie.com/embed/a7UFm6ErMPU']" end end