4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/true_url/strategy/vimeo.rb', line 4
def execute(context)
path = context.working_url.path
if context.working_url.host == 'player.vimeo.com'
video_id = path[7..-1]
elsif path =~ /^\/channels\/\w+\/\d+$/
video_id = path.split('/').last
elsif path =~ /^\/\d+$/
video_id = path[1..-1]
end
if video_id
context.set_working_url("https://vimeo.com/#{video_id}")
context.finalize
context.attributes[:embed_url] = "https://player.vimeo.com/video/#{video_id}"
end
context.working_url.scheme = 'https'
end
|