Commit 9bcbe6a3 by Taylor Otwell

fix bug in route handles method.

parent 7fa80bcd
......@@ -214,11 +214,11 @@ class Route {
*/
public function handles($uri)
{
$pattern = '#'.str_replace('*', '(.*)', $uri).'#';
$pattern = ($uri !== '/') ? str_replace('*', '(.*)', $uri) : '^/$';
return ! is_null(array_first($this->uris, function($key, $uri) use ($pattern)
{
return preg_match($pattern, $uri);
return preg_match('#'.$pattern.'#', $uri);
}));
}
......
......@@ -19,10 +19,11 @@ class RouteTest extends PHPUnit_Framework_TestCase {
{
$route = new Laravel\Routing\Route('GET /', array('handles' => array('GET /foo/bar')));
$this->assertFalse($route->handles('/'));
$this->assertFalse($route->handles('baz'));
$this->assertTrue($route->handles('foo/*'));
$this->assertTrue($route->handles('foo/bar'));
$this->assertFalse($route->handles('/'));
$this->assertFalse($route->handles('baz'));
$this->assertFalse($route->handles('/foo'));
$route = new Laravel\Routing\Route('GET /', array('handles' => array('GET /', 'GET /home')));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment