From 396d1332e1ad6d0570fc90c9c202201ac9ec1363 Mon Sep 17 00:00:00 2001 From: Joe Green Date: Fri, 14 Nov 2014 08:55:53 +0000 Subject: [PATCH] fix escaping in reverse routes --- src/Phroute/RouteParser.php | 4 ++-- test/Dispatcher/DispatcherTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Phroute/RouteParser.php b/src/Phroute/RouteParser.php index 9ecbe15..7018998 100644 --- a/src/Phroute/RouteParser.php +++ b/src/Phroute/RouteParser.php @@ -153,9 +153,9 @@ private function staticParts($route, $nextOffset) { if($staticPart) { - $staticPart = $this->quote($staticPart); + $quotedPart = $this->quote($staticPart); - $this->parts[$this->partsCounter] = $staticPart; + $this->parts[$this->partsCounter] = $quotedPart; $this->reverseParts[$this->partsCounter] = array( 'variable' => false, diff --git a/test/Dispatcher/DispatcherTest.php b/test/Dispatcher/DispatcherTest.php index 1f7d910..0939d68 100644 --- a/test/Dispatcher/DispatcherTest.php +++ b/test/Dispatcher/DispatcherTest.php @@ -169,6 +169,16 @@ public function testOptionalReverseRoute() $this->assertEquals('products/store/1', $r->route('products', array(1))); } + public function testReverseRouteWithDashes() + { + $r = $this->router(); + + $r->any( array('product-catalogue/store/{store:i}?', 'products'), array(__NAMESPACE__.'\\Test','route')); + + $this->assertEquals('product-catalogue/store', $r->route('products')); + $this->assertEquals('product-catalogue/store/1', $r->route('products', array(1))); + } + /** * @expectedException \Phroute\Exception\BadRouteException * @expectedExceptionMessage Expecting route variable 'store'