FIX: use Vimeo engine for private links only FIX: if og:video_url is missing, make one using Vimeo ID

FIX: use Vimeo engine for private links only FIX: if og:video_url is missing, make one using Vimeo ID

diff --git a/lib/onebox/engine/vimeo_onebox.rb b/lib/onebox/engine/vimeo_onebox.rb
index 10c73b6..a2fd774 100644
--- a/lib/onebox/engine/vimeo_onebox.rb
+++ b/lib/onebox/engine/vimeo_onebox.rb
@@ -4,7 +4,8 @@ module Onebox
       include Engine
       include StandardEmbed
 
-      matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+(\/[^\/]+)?$/)
+      # only match private Vimeo video links
+      matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+\/[^\/]+?$/)
       always_https
 
       WIDTH  ||= 640
@@ -17,6 +18,10 @@ module Onebox
 
       def to_html
         video_src = og_data.video_secure_url || og_data.video_url
+        if video_src.nil?
+          id = uri.path[/\/(\d+)/, 1]
+          video_src = "https://player.vimeo.com/video/#{id}"
+        end
         video_src = video_src.gsub('autoplay=1', '').chomp("?")
         <<-HTML
           <iframe width="#{WIDTH}"

GitHub sha: c43ba86f

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there: