Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1115 from kawazrepos/support-shorten-url
Browse files Browse the repository at this point in the history
Support shorten YouTube URL closes #1102
  • Loading branch information
giginet committed Nov 27, 2016
2 parents eab2219 + 853f035 commit ac344fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/kawaz/apps/kfm/extras/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


PATTERN = re.compile(
r"https?://www\.youtube\.com/watch\?v=(?P<id>[a-zA-Z0-9_\-]+)"
r"https?://(:?www\.youtube\.com/watch\?v=|youtu\.be/)(?P<id>[a-zA-Z0-9_\-]+)"
)
TEMPLATE_NAME = r"kfm/extras/youtube.html"

Expand Down
6 changes: 6 additions & 0 deletions src/kawaz/apps/kfm/tests/test_extras/test_youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def test_parse_youtube_urls(self):
value = parse_youtube_urls(value)
self.assertEqual(value, self._render_template(self.video_id))

def test_parse_shorten_youtube_urls(self):
"""短縮されたYouTubeのURLは展開される"""
value = "https://youtu.be/{}".format(self.video_id)
value = parse_youtube_urls(value)
self.assertEqual(value, self._render_template(self.video_id))

def test_parse_youtube_urls_responsive(self):
"""YouTubeのURLはレスポンシブ展開される"""
value = self.template_str.format(self.video_id)
Expand Down

0 comments on commit ac344fe

Please sign in to comment.