fix bug in route handles method.
This commit is contained in:
parent
7fa80bcdba
commit
9bcbe6a357
|
@ -214,11 +214,11 @@ public function is($name)
|
||||||
*/
|
*/
|
||||||
public function handles($uri)
|
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 ! 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 @@ public function testHandlesIndicatesIfTheRouteHandlesAGivenURI()
|
||||||
{
|
{
|
||||||
$route = new Laravel\Routing\Route('GET /', array('handles' => array('GET /foo/bar')));
|
$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/*'));
|
||||||
$this->assertTrue($route->handles('foo/bar'));
|
$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')));
|
$route = new Laravel\Routing\Route('GET /', array('handles' => array('GET /', 'GET /home')));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue