diff --git a/Imagine/Cache/Resolver/WebPathResolver.php b/Imagine/Cache/Resolver/WebPathResolver.php index 480808291..5d1b6c51e 100644 --- a/Imagine/Cache/Resolver/WebPathResolver.php +++ b/Imagine/Cache/Resolver/WebPathResolver.php @@ -117,7 +117,7 @@ protected function getFilePath($path, $filter) */ protected function getFileUrl($path, $filter) { - return $this->cachePrefix.'/'.$filter.'/'.$path; + return $this->cachePrefix.'/'.$filter.'/'.ltrim($path, '/'); } /** diff --git a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php index c43651b8c..eb58e8e6d 100644 --- a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php @@ -414,6 +414,24 @@ public function testRemoveCacheForSomeFiltersOnRemove() $resolver->remove(array(), array('aFilterOne', 'aFilterTwo')); } + public function testShouldRemoveDoubleSlashInUrl() + { + $resolver = new WebPathResolver( + $this->createFilesystemMock(), + new RequestContext, + '/aWebRoot', + 'aCachePrefix' + ); + + $rc = new \ReflectionClass($resolver); + $method = $rc->getMethod('getFileUrl'); + $method->setAccessible(true); + + $result = $method->invokeArgs($resolver, array('/cats.jpg', 'some_filter')); + + $this->assertEquals('aCachePrefix/some_filter/cats.jpg', $result); + } + /** * @return \PHPUnit_Framework_MockObject_MockObject|Filesystem */