Skip to content

Commit a6734e1

Browse files
committed
Merge pull request #17 from damienalexandre/urlparser
Fix the parser when path is empty
2 parents 235dc23 + b790407 commit a6734e1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Embed/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public function setPath ($path) {
416416
* Return the url path
417417
*/
418418
public function getPath ($file = false) {
419-
$path = isset($this->info['path']) ? '/'.implode('/', $this->info['path']).'/' : '/';
419+
$path = isset($this->info['path']) && !empty($this->info['path']) ? '/'.implode('/', $this->info['path']).'/' : '/';
420420

421421
if ($file && !empty($this->info['file'])) {
422422
$path .= $this->info['file'];

tests/EmbedTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,19 @@ public function testUrls () {
8181
)
8282
);
8383
}
84-
}
84+
85+
public function testUrlParser()
86+
{
87+
$urls = array(
88+
'http://vimeo.com//69912181?' => 'http://vimeo.com/69912181',
89+
'http://vimeo.com//69912181' => 'http://vimeo.com/69912181',
90+
'http://vimeo.com/69912181' => 'http://vimeo.com/69912181',
91+
);
92+
93+
foreach ($urls as $url => $expected_url) {
94+
$parsed_url = new Embed\Url($url);
95+
96+
$this->assertEquals($expected_url, $parsed_url->getUrl());
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)