Commit b6fffeb0 by Qiang Xue

Removed trailing slash in created URLs.

parent e6b52b85
...@@ -14,9 +14,9 @@ class UrlManagerTest extends \yiiunit\TestCase ...@@ -14,9 +14,9 @@ class UrlManagerTest extends \yiiunit\TestCase
'cache' => null, 'cache' => null,
)); ));
$url = $manager->createUrl('post/view'); $url = $manager->createUrl('post/view');
$this->assertEquals('/?r=post/view', $url); $this->assertEquals('?r=post/view', $url);
$url = $manager->createUrl('post/view', array('id' => 1, 'title' => 'sample post')); $url = $manager->createUrl('post/view', array('id' => 1, 'title' => 'sample post'));
$this->assertEquals('/?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('?r=post/view&id=1&title=sample+post', $url);
// default setting with '/test/' as base url // default setting with '/test/' as base url
$manager = new UrlManager(array( $manager = new UrlManager(array(
...@@ -24,7 +24,7 @@ class UrlManagerTest extends \yiiunit\TestCase ...@@ -24,7 +24,7 @@ class UrlManagerTest extends \yiiunit\TestCase
'cache' => null, 'cache' => null,
)); ));
$url = $manager->createUrl('post/view', array('id' => 1, 'title' => 'sample post')); $url = $manager->createUrl('post/view', array('id' => 1, 'title' => 'sample post'));
$this->assertEquals('/test/?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('/test?r=post/view&id=1&title=sample+post', $url);
// pretty URL without rules // pretty URL without rules
$manager = new UrlManager(array( $manager = new UrlManager(array(
...@@ -112,7 +112,7 @@ class UrlManagerTest extends \yiiunit\TestCase ...@@ -112,7 +112,7 @@ class UrlManagerTest extends \yiiunit\TestCase
'cache' => null, 'cache' => null,
)); ));
$url = $manager->createAbsoluteUrl('post/view', array('id' => 1, 'title' => 'sample post')); $url = $manager->createAbsoluteUrl('post/view', array('id' => 1, 'title' => 'sample post'));
$this->assertEquals('http://www.example.com/?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('http://www.example.com?r=post/view&id=1&title=sample+post', $url);
} }
public function testParseRequest() public function testParseRequest()
......
...@@ -203,7 +203,7 @@ class UrlManager extends Component ...@@ -203,7 +203,7 @@ class UrlManager extends Component
} }
return "$baseUrl/{$route}{$anchor}"; return "$baseUrl/{$route}{$anchor}";
} else { } else {
$url = "$baseUrl/?{$this->routeVar}=$route"; $url = "$baseUrl?{$this->routeVar}=$route";
if (!empty($params)) { if (!empty($params)) {
$url .= '&' . http_build_query($params); $url .= '&' . http_build_query($params);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment