diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 8309dab978b..ca9c47bb4a8 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -35,7 +35,7 @@ class View { } public function getAbsolutePath($path = '/') { - if (!$path) { + if ($path === '') { $path = '/'; } if ($path[0] !== '/') { diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index d793aebffab..c26c6f29fc0 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -578,4 +578,22 @@ class View extends \PHPUnit_Framework_TestCase { $info2 = $view->getFileInfo('/test/test'); $this->assertEquals($info['etag'], $info2['etag']); } + + /** + * @dataProvider absolutePathProvider + */ + public function testGetAbsolutePath($expectedPath, $relativePath) { + $view = new \OC\Files\View('/files'); + $this->assertEquals($expectedPath, $view->getAbsolutePath($relativePath)); + } + + function absolutePathProvider() { + return array( + array('/files/', ''), + array('/files/0', '0'), + array('/files/', '/'), + array('/files/test', 'test'), + array('/files/test', '/test'), + ); + } }