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

Commit

Permalink
Merge pull request #5 from hashworks/parser/handleEmbedURLs
Browse files Browse the repository at this point in the history
Add parser for embed URLs
  • Loading branch information
elazar committed Jun 15, 2015
2 parents 5fa167c + 570d51d commit 5b594c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ protected function getVideoId($url)
if (!empty($query['v'])) {
return $query['v'];
}
} elseif (isset($parsed['path']) && substr($parsed['path'], 0, 7) == '/embed/') {
$logger->debug('getVideoId', array('url' => $url, 'path' => $parsed['path']));
$vId = substr($parsed['path'], 7);
if (!empty($vId)) {
return $vId;
}
}
}
return null;
Expand Down
2 changes: 2 additions & 0 deletions tests/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public function dataProviderHandleUrl()
{
return array(
array('http://www.youtube.com/watch?v=HFuTvTVAO-M'),
array('https://www.youtube.com/embed/HFuTvTVAO-M'),
array('https://youtube.com/embed/HFuTvTVAO-M'),
array('http://youtube.com/watch?v=HFuTvTVAO-M'),
array('http://youtu.be/HFuTvTVAO-M'),
);
Expand Down

0 comments on commit 5b594c2

Please sign in to comment.