Vimeo provides two types of urls: direct links (https://vimeo.com/508864124/fcbbcc92fa) and embed links (which can be used in an iframe, but won’t work if clicked directly)
When this is sent as a notification email, the direct link appears correctly, but the iframe is replaced into a link with the wrong URL: https://vimeo.com/508864124?h=fcbbcc92fa instead of https://player.vimeo.com/video/508864124?h=fcbbcc92fa
Even worse, if a (valid) trailing slash is added in the embed URL, the video id is removed in the email: <iframe src="https://player.vimeo.com/video/508864124/?h=fcbbcc92fa" ...></iframe> becomes https://vimeo.com/?h=fcbbcc92fa
Is there a way to bypass the iframe-to-URL conversion altogether? Just like we already do with polls, it says something like “Click here to see the poll”
I have submitted a PR to fix, I think the problem was with regex pattern. It didn’t captured vimeo correcly when its not the standard type. Thus I changed the regex pattern accordingly.
Gets transformed into this (which is a 404): https://vimeo.com/508864124?h=fcbbcc92fa
Instead of the correct URL: https://vimeo.com/508864124/fcbbcc92fa
Maybe the regex that you added in your PR needs an extra step (transform ?h= into / when sending an email)
Yes. The regex change you did made it possible to recognize iframe src URLs (https://player.vimeo.com/video/508864124?h=fcbbcc92fa), so that’s no longer a problem. The issue is on the email that gets sent.
If you paste a plain url (https://vimeo.com/508864124/fcbbcc92fa), there’s no issue. It’s only a problem with the iframe src (https://player.vimeo.com/video/508864124?h=fcbbcc92fa).
It currently does.
Yes. Currently, the iframe src (https://player.vimeo.com/video/508864124?h=fcbbcc92fa) gets converted to this: https://vimeo.com/508864124?h=fcbbcc92fa instead of this: https://vimeo.com/508864124/fcbbcc92fa
It’s still hard for me to reproduce because I need to have a premium account to have unlisted video on vimeo.
Also I think your example of video above allow only to loaded from certiain domain, can you allow my sandbox instance to load it as well: https://discuss.gsgapp.io.
Again and be crystal clear, you don’t expect the video to play on E-mail, but you expect when people click on video position to be directed to the correct url? Am I right with that?
So what is happening is that when you paste vanila iframe code, then you might bypass onebox code, and if you pass it then the result iframe code will not have data-original-href which is the link that is used in email template.
And when data-original-href is missing discourse tries to guess to the video is that is whatever is after the last / which is of course doesn’t cover the case of unlisted video.
For example if you check the dev tools/inspect element from your browser, the result iframe when using vanfila iframe code:
So notice the extra data-original-href="https://vimeo.com/508864124/fcbbcc92fa" in the second output, one might guess if that attribute when using iframe vanilla then it should work, but it doesn’t probably because discourse doesn’t allow you to add any attriubte you want…
I think I can suggest a solution, and while ensuring it would work for the case when the video is listed/public I came with this ucommon beahvour of vimeo. So typically all videos that are public folllow this pattern vimeo.com/{id} however it will work if you add a slash i.e. vimeo.com/{id}/anything
Consider the following example:
https://vimeo.com/767548129/estgsetgset
https://vimeo.com/767548129/hey-discurse
https://vimeo.com/767548129The normal
All the above lead to the same video, so the fix can be that to create a url from iframe src, vimeo.com/{_what comes after the first slash}/{What comes from the h=} This shall make it work for both cases.
In all cases it lead to the email generating the correct url.
But anyway please try to test for all other possible variation that you might encournter and most importantly that it doesn’t break other thing.
The way I tested the e-mail template is that I would send myself a direct message, and then check the email inbox. (Since I have two accounts regitered at https://discuss.gsgapp.io)