1. Peter Hosey
  2. Shorten URLs service

Commits

Peter Hosey  committed ade5b4f

Fix the .be suffix creeping in when shortening a URL that has been previously shortened and then unshortened.

  • Participants
  • Parent commits 3e2fb51
  • Branches default

Comments (0)

Files changed (2)

File Makefile

View file
 	echo 'http://youtu.be/1c5qpAH8YKo' >> youtube.out.correct
 	echo 'youtube.com/watch?v=1c5qpAH8YKo' | ./Shorten-URLs.py >> youtube.out
 	echo 'http://youtu.be/1c5qpAH8YKo' >> youtube.out.correct
+	echo 'http://www.youtube.com/watch?v=DtkoAlwIpWY&feature=youtu.be' | ./Shorten-URLs.py >> youtube.out
+	echo 'http://youtu.be/DtkoAlwIpWY' >> youtube.out.correct
 	diff -u youtube.out.correct youtube.out
 
 test-techcrunch:

File Shorten-URLs.py

View file
 	short_URL_exp = re.compile('<link rel="shorturl" href="(http://tmo.to/[A-Za-z0-9]+)" ?/?>')
 
 class YouTubeURLShortener(URLShortener):
-	canonical_URL_exp = re.compile('(?:http://)?(?:www\.)?(youtube\.com/watch\?)(?:[-_a-zA-Z0-9]+=[-_a-zA-Z0-9]+&)*v=([-_a-zA-Z0-9]+)(?:&[-_a-zA-Z0-9]+=[-_a-zA-Z0-9]+)*')
+	canonical_URL_exp = re.compile('(?:http://)?(?:www\.)?(youtube\.com/watch\?)(?:[-_a-zA-Z0-9]+=[-_a-zA-Z0-9]+&)*v=([-_a-zA-Z0-9]+)(?:&[-_a-zA-Z0-9]+=[-_a-zA-Z0-9]+(?:\.be)?)*')
 
 	def shorten_URL_from_match(self, match):
 		video_ID = match.group(2)