vime-js / vime

Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
https://vimejs.com
MIT License
2.75k stars 154 forks source link

bug: exception thrown when vimeo thumbnail_url does not exist #246

Open delta1186 opened 3 years ago

delta1186 commented 3 years ago

Bug Report

Vime version:

5.0.33

Provider:

[X] Vimeo`

Current behavior:

The issue I am having is with the thumbnail_url where I am getting a "cannot read properties of undefined....at p-d12ace9b.entry.js" in browser. The error is thrown on the thumbnail_url.match when the vimeo video response does not have a thumbnail_url because the video is private. https://developer.vimeo.com/api/oembed/videos#embedding-videos-with-domain-privacy

Expected behavior:

The page should load regardless of their being an available thumbnail.

Steps to reproduce:

Reference a private vimeo video. Thumbnail urls are not available for private videos. Source: https://developer.vimeo.com/api/oembed/videos#embedding-videos-with-domain-privacy

Related code:

https://github.com/vime-js/vime/blob/a898432f2a0d0de19ac1986b963b4e3a7c25e822/packages/core/src/components/providers/vimeo/vimeo.tsx#L242

Adding the second optional chaining operator after thumbnail_url resolves this issue.

const thumbnailId = data?.thumbnail_url?.match(thumnailRegex)[1];

I have tested this locally and it does indeed resolve the issue. I will be submitting a PR for this in a few minutes.