From 3dbd698397f041569cb729822a5ea7e909af62a5 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 31 Mar 2010 14:56:21 -0400 Subject: [PATCH] Added a new URL format for the Youtube class. Created a test for the new URL format. --- 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 532d8ca..ee9a115 100644 --- a/src/websites/youtube.rb +++ b/src/websites/youtube.rb @@ -21,7 +21,7 @@ require 'cgi' class Youtube < Website - VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?([a-z0-9]+\.)?youtube\.com\/((watch\?v=)|(v\/))[a-z0-9_\-]+(\&.*)?\#?$/i + VALID_YOUTUBE_URL_REGEX = /^(http:\/\/)?([a-z0-9]+\.)?youtube\.com\/((watch\?v=)|(v\/)|([a-z]+\#[a-z]\/[a-z]\/[0-9]\/))[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 ec91d35..ab92f2d 100644 --- a/test/youtube_test.rb +++ b/test/youtube_test.rb @@ -35,6 +35,7 @@ class YoutubeTest < Test::Unit::TestCase 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')) + assert(Youtube.owns_url?('http://www.youtube.com/meetlocalbiz#p/u/0/rJVWV4aA6Jk')) end -- 2.44.2