Skip to content

Commit

Permalink
Cleanup video reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
vpodk committed Jan 28, 2024
1 parent 020d725 commit 3bc77f7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/app/components/search/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@ const Videos = ({ product }: { product: Product }) => {
product.dupe_video_reference_link_1,
product.dupe_video_reference_link_2,
product.dupe_video_reference_link_3,
].map((video) => {
if (video && video.startsWith("http")) {
].map((url) => {
if (url && url.startsWith("http")) {
try {
// "https://www.youtube.com/shorts/qwerty",
let id = video.split("/shorts/")[1];
if (!id) {
let videoId = url.split("/shorts/")[1];
if (!videoId) {
// "https://www.youtube.com/watch?v=aaa&pp=bbb"
id = new URLSearchParams(video.split("?")[1]).get("v");
videoId = new URLSearchParams(url.split("?")[1]).get("v");
}
const src = "https://www.youtube.com/embed/" + id;
const src = "https://www.youtube.com/embed/" + videoId;
return (
<iframe
key={videoId}
className="m-6 w-3/5 min-h-96"
allowFullScreen
src={src}
Expand Down

0 comments on commit 3bc77f7

Please sign in to comment.