diff --git a/Mf2/Parser.php b/Mf2/Parser.php index 14f432b..5c26f80 100644 --- a/Mf2/Parser.php +++ b/Mf2/Parser.php @@ -442,7 +442,7 @@ public function parseP(\DOMElement $p) { public function parseU(\DOMElement $u) { if (($u->tagName == 'a' or $u->tagName == 'area') and $u->getAttribute('href') !== null) { $uValue = $u->getAttribute('href'); - } elseif ($u->tagName == 'img' and $u->getAttribute('src') !== null) { + } elseif (in_array($u->tagName, array('img', 'audio', 'video', 'source')) and $u->getAttribute('src') !== null) { $uValue = $u->getAttribute('src'); } elseif ($u->tagName == 'object' and $u->getAttribute('data') !== null) { $uValue = $u->getAttribute('data'); diff --git a/tests/Mf2/ParseUTest.php b/tests/Mf2/ParseUTest.php index 697b449..26a9023 100644 --- a/tests/Mf2/ParseUTest.php +++ b/tests/Mf2/ParseUTest.php @@ -136,4 +136,43 @@ public function testParsesHrefBeforeValueClass() { $result = Mf2\parse($input); $this->assertEquals('http://example.com/right', $result['items'][0]['properties']['url'][0]); } + + /** + * @group parseU + */ + public function testParseUHandlesAudio() { + $input = '
'; + $parser = new Parser($input); + $output = $parser->parse(); + + $this->assertArrayHasKey('audio', $output['items'][0]['properties']); + $this->assertEquals('http://example.com/audio.mp3', $output['items'][0]['properties']['audio'][0]); + } + + /** + * @group parseU + */ + public function testParseUHandlesVideo() { + $input = ''; + $parser = new Parser($input); + $output = $parser->parse(); + + $this->assertArrayHasKey('video', $output['items'][0]['properties']); + $this->assertEquals('http://example.com/video.mp4', $output['items'][0]['properties']['video'][0]); + } + + + /** + * @group parseU + */ + public function testParseUHandlesSource() { + $input = ''; + $parser = new Parser($input); + $output = $parser->parse(); + + $this->assertArrayHasKey('video', $output['items'][0]['properties']); + $this->assertEquals('http://example.com/video.mp4', $output['items'][0]['properties']['video'][0]); + $this->assertEquals('http://example.com/video.ogg', $output['items'][0]['properties']['video'][1]); + } + }