Fixing trailing slash in URL when extension is used (Ticket #2934)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5439 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-07-17 13:45:20 +00:00
parent 4d4cf07c84
commit 2664ed2ee4
2 changed files with 9 additions and 0 deletions

View file

@ -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;
}
/**

View file

@ -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(