Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of #369 (Trim of forwarding slash in path) #401

Merged
merged 3 commits into from
Apr 29, 2014
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Imagine/Cache/Resolver/WebPathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/');
}

/**
Expand Down
18 changes: 18 additions & 0 deletions Tests/Imagine/Cache/Resolver/WebPathResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Me1ifaro please do assertEquals

}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|Filesystem
*/
Expand Down