From ea8c6e18251619f3842e6c8e43a796e276c84181 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Thu, 19 Jan 2012 08:47:17 -0500 Subject: [PATCH] Fixed route handles for uri's that partially match --- laravel/routing/route.php | 4 ++-- tests/cases/laravel/route.test.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/laravel/routing/route.php b/laravel/routing/route.php index 96629c60..4d0ce72e 100644 --- a/laravel/routing/route.php +++ b/laravel/routing/route.php @@ -118,7 +118,7 @@ public function call() */ public function response() { - // If the action is a string, it is simply pointing the route to a + // If the action is a string, it is simply pointing the route to a // controller action, and we can just call the action and return // its response. This is the most basic form of route, and is // the simplest to handle. @@ -214,7 +214,7 @@ public function is($name) */ public function handles($uri) { - $pattern = ($uri !== '/') ? str_replace('*', '(.*)', $uri) : '^/$'; + $pattern = ($uri !== '/') ? str_replace('*', '(.*)', $uri).'\z' : '^/$'; return ! is_null(array_first($this->uris, function($key, $uri) use ($pattern) { diff --git a/tests/cases/laravel/route.test.php b/tests/cases/laravel/route.test.php index 7677d9e1..135db35e 100644 --- a/tests/cases/laravel/route.test.php +++ b/tests/cases/laravel/route.test.php @@ -24,6 +24,7 @@ public function testHandlesIndicatesIfTheRouteHandlesAGivenURI() $this->assertFalse($route->handles('/')); $this->assertFalse($route->handles('baz')); $this->assertFalse($route->handles('/foo')); + $this->assertFalse($route->handles('foo')); $route = new Laravel\Routing\Route('GET /', array('handles' => array('GET /', 'GET /home')));