From 5e8665cd8db05b4dc2804baa36d878c70724bbe9 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 20 Mar 2010 17:57:01 -0300 Subject: [PATCH] Allowing routes to set an extension when Router::parseExtension() is being used. Fixes #492 Signed-off-by: Mark Story --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 9d311607e..0c988ac35 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -497,7 +497,7 @@ class Router { } } - if (!empty($ext)) { + if (!empty($ext) && !isset($out['url']['ext'])) { $out['url']['ext'] = $ext; } return $out; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 99b549cfc..82b4604ec 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1212,6 +1212,13 @@ class RouterTest extends CakeTestCase { $result = Router::parse('/controller/action'); $expected = array('controller' => 'controller', 'action' => 'action', 'plugin' => null, 'url' => array('ext' => 'rss'), 'named' => array(), 'pass' => array()); $this->assertEqual($result, $expected); + + Router::reload(); + Router::parseExtensions('rss'); + Router::connect('/controller/action', array('controller' => 'controller', 'action' => 'action', 'url' => array('ext' => 'rss'))); + $result = Router::parse('/controller/action'); + $expected = array('controller' => 'controller', 'action' => 'action', 'plugin' => null, 'url' => array('ext' => 'rss'), 'named' => array(), 'pass' => array()); + $this->assertEqual($result, $expected); } /**