Fix relative URLs for video tag
authorPhilippe Lovis <rumdidumdum@users.noreply.github.com>
Sun, 11 Jan 2015 10:01:04 +0000 (11:01 +0100)
committerPhilippe Lovis <rumdidumdum@users.noreply.github.com>
Sun, 11 Jan 2015 10:01:04 +0000 (11:01 +0100)
Fixes issue #1127. The markup regex only matched URLs beginning with 'http'.
This change adds support for relative URLs beginning with '/'. The regex is
based on the one used in image_tag.rb.

plugins/video_tag.rb

index c6e67b7..2a82b05 100644 (file)
@@ -22,11 +22,11 @@ module Jekyll
     @width = ''
 
     def initialize(tag_name, markup, tokens)
-      if markup =~ /(https?:\S+)(\s+(https?:\S+))?(\s+(https?:\S+))?(\s+(\d+)\s(\d+))?(\s+(https?:\S+))?/i
-        @video  = [$1, $3, $5].compact
-        @width  = $7
-        @height = $8
-        @poster = $10
+      if markup =~ /((https?:\/\/|\/)\S+)(\s+((https?:\/\/|\/)\S+))?(\s+((https?:\/\/|\/)\S+))?(\s+(\d+)\s(\d+))?(\s+((https?:\/\/|\/)\S+))?/i
+        @video  = [$1, $4, $7].compact
+        @width  = $10
+        @height = $11
+        @poster = $13
       end
       super
     end