Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: canPlay is returning true for all facebook URLs #793

Closed
sapkra opened this issue Feb 1, 2020 · 9 comments
Closed

Bug: canPlay is returning true for all facebook URLs #793

sapkra opened this issue Feb 1, 2020 · 9 comments

Comments

@sapkra
Copy link

sapkra commented Feb 1, 2020

Current Behavior

After the new update the canPlay function is returning true for all facebook URLs because of the new matcher. This results in a lot of false positives.

Expected Behavior

canPlay should only return true if it actually can be played.

@cookpete
Copy link
Owner

cookpete commented Feb 1, 2020

If anyone can find or create a regex pattern that matches all playable facebook URLs (and solves #778) I'll be happy to use it.

@paulincai
Copy link

@sapkra @cookpete let's start with this. @sapkra are you aware of any url formats that don't work with it?

 const url = ..................
 const matchFacebookUrl = /facebook\.com\/([^/?].+\/)?video(s|\.php)[/?].*$/
 const isFBVideo = matchFacebookUrl.test(url)
 console.log(isFBVideo)

@cookpete
Copy link
Owner

cookpete commented Feb 1, 2020

@paulincai That pattern doesn't match the URL in #778

I'm tempted by this:

^https?://www\.facebook\.com.*/(video|watch).+$

Which just matches any facebook.com url that contains /watch or /video somewhere in it. Quite terse but still covers most use cases:

https://regex101.com/r/VW2BBg/2

@sapkra
Copy link
Author

sapkra commented Feb 2, 2020

@cookpete I've improved it a bit to not match any facebook pages which include watch or video.

https://regexr.com/4tdur

@paulincai
Copy link

@cookpete I get it.

Not related to the present issue/task, the thing is that I use a scrapper for all web content that lands in my platform and the URL in #778, "https://www.facebook.com/watch/?v=499831560618548" ends up as "https://www.facebook.com/francknicolasofficiel/videos/499831560618548/"
This is the "real" URL that ReactPlayer actually plays because the FB SDK returns this URL not the "watch" url.

And now I remember that I decided to rely on the scrapper for consistency of all URLs having them correctly formatted before saving to DB.

I am for @sapkra 's regex. I think it covers well.

@cookpete
Copy link
Owner

cookpete commented Feb 2, 2020

Nice one @sapkra. Updated and published in react-player@1.15.1. Cheers all for the help.

@paulincai
Copy link

ok, here's another one, at least for the reference. There is a video URL format which re-re-directs in Facebook.

This is a video content: https://www.facebook.com/story.php?story_fbid=10156618238668888&id=9328458887

the video URL is https://www.facebook.com/adidasoriginals/videos/10156618238668888/

@sapkra
Copy link
Author

sapkra commented Feb 2, 2020

@paulincai Updated the regex in my link to also match this one if necessary.

@cookpete
Copy link
Owner

cookpete commented Feb 2, 2020

Updated regex in react-player@1.15.2

albanqoku added a commit to albanqoku/react-player that referenced this issue Feb 24, 2021
Webmaster1116 added a commit to Webmaster1116/video-player that referenced this issue May 20, 2021
webmiraclepro added a commit to webmiraclepro/video-player that referenced this issue Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants