From 4935683016a5378ca4cc67f12816178421c359cf Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 1 Mar 2009 19:14:09 -0500 Subject: [PATCH] Updated the Youtube URL regex to allow any hostname.youtube.com pattern. Added a test to ensure that uk.youtube.com URLs are handled properly. --- src/websites/youtube.rb | 2 +- test/youtube_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/websites/youtube.rb b/src/websites/youtube.rb index 3388100..cbda4e2 100644 --- a/src/websites/youtube.rb +++ b/src/websites/youtube.rb @@ -26,7 +26,7 @@ require 'uri' class Youtube < Website - VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?(www\.)?(in\.)?youtube\.com\/((watch\?v=)|(v\/))[a-z0-9_\-]+(\&.*)?\#?$/i + VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?([a-z0-9]+\.)?youtube\.com\/((watch\?v=)|(v\/))[a-z0-9_\-]+(\&.*)?\#?$/i def self.owns_url?(url) return url =~ VALID_YOUTUBE_URL_REGEX diff --git a/test/youtube_test.rb b/test/youtube_test.rb index 507e43e..fa61cb2 100644 --- a/test/youtube_test.rb +++ b/test/youtube_test.rb @@ -34,6 +34,7 @@ class YoutubeTest < Test::Unit::TestCase assert(Youtube.owns_url?('http://www.youtube.com/watch?v=83-hlYMH1XE')) assert(Youtube.owns_url?('http://www.youtube.com/watch?v=83-hlYMH1XE&feature=dir')) assert(Youtube.owns_url?('http://in.youtube.com/watch?v=VcydqSpYN00&feature=channel_page')) + assert(Youtube.owns_url?('http://uk.youtube.com/watch?v=LN4Ov6ZLcrI')) end -- 2.44.2