From 94f44654afb9f91acd63a6b76f578b5fbf4ec3d8 Mon Sep 17 00:00:00 2001 From: Iakov Mishchenko Date: Tue, 22 Apr 2014 20:49:02 +0300 Subject: [PATCH 1/3] Fix of #369 (Trim of forwarding slash in path) --- Imagine/Cache/Resolver/WebPathResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, '/'); } /** From e9d5f8757367fac8abd79789b0df64c6839e247e Mon Sep 17 00:00:00 2001 From: Iakov Mishchenko Date: Thu, 24 Apr 2014 11:41:19 +0300 Subject: [PATCH 2/3] Added test --- .../Cache/Resolver/WebPathResolverTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php index c43651b8c..4e69f2138 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->assertNotContains('//', $result); + } + /** * @return \PHPUnit_Framework_MockObject_MockObject|Filesystem */ From 94ed8fb52d0e338d7476ab3f4748f1db16cd9408 Mon Sep 17 00:00:00 2001 From: Iakov Mishchenko Date: Tue, 29 Apr 2014 14:59:58 +0300 Subject: [PATCH 3/3] Fixed test --- Tests/Imagine/Cache/Resolver/WebPathResolverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php index 4e69f2138..eb58e8e6d 100644 --- a/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/WebPathResolverTest.php @@ -429,7 +429,7 @@ public function testShouldRemoveDoubleSlashInUrl() $result = $method->invokeArgs($resolver, array('/cats.jpg', 'some_filter')); - $this->assertNotContains('//', $result); + $this->assertEquals('aCachePrefix/some_filter/cats.jpg', $result); } /**