lib/youtube_id.rb in youtube_id-0.0.3 vs lib/youtube_id.rb in youtube_id-0.1.0
- old
+ new
@@ -1,13 +1,13 @@
require "youtube_id/version"
module YoutubeID
FORMATS = [
- %r(https?://youtu\.be/(.+)),
- %r(https?://www\.youtube\.com/watch\?v=(.*?)(&|#|$)),
- %r(https?://www\.youtube\.com/embed/(.*?)(\?|$)),
- %r(https?://www\.youtube\.com/v/(.*?)(#|\?|$)),
- %r(https?://www\.youtube\.com/user/.*?#\w/\w/\w/\w/(.+)\b)
+ %r((?:https?://)?youtu\.be/(.+)),
+ %r((?:https?://)?(?:www\.)?youtube\.com/watch\?v=(.*?)(&|#|$)),
+ %r((?:https?://)?(?:www\.)?youtube\.com/embed/(.*?)(\?|$)),
+ %r((?:https?://)?(?:www\.)?youtube\.com/v/(.*?)(#|\?|$)),
+ %r((?:https?://)?(?:www\.)?youtube\.com/user/.*?#\w/\w/\w/\w/(.+)\b)
]
def self.from(video_url)
video_url.strip!
FORMATS.find { |format| video_url =~ format } and $1