diff --git a/cake/libs/router.php b/cake/libs/router.php index 7111aab2c..7d638b01e 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -601,6 +601,9 @@ class Router extends Object { if ($full) { $output = FULL_BASE_URL . $output; } + if(!empty($extension) && substr($output, -1) == '/') { + $output = substr($output, 0, -1); + } return $output . $extension . $_this->queryString($q) . $frag; } /** diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 3f2e5fb0d..9f4db125d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -158,6 +158,12 @@ class RouterTest extends UnitTestCase { $this->assertEqual($result, $expected); } + function testUrlGenerationWithExtensions() { + $result = $this->router->url(array('plugin' => null, 'controller' => 'articles', 'action' => 'add', 'id' => null, 'ext' => 'json')); + $expected = '/articles/add.json'; + $this->assertEqual($result, $expected); + } + function testPluginUrlGeneration() { $this->router->setRequestInfo(array( array(