Permalink
Browse files

Merge pull request #45 from joeytrapp/router-reverse

Generate full url from Router::reverse(). Fixes #1638
  • Loading branch information...
markstory committed May 11, 2011
2 parents e53407c + 6a8322a commit eb1e040ae996fca6de54279f5dd1431def23f96c
Showing with 13 additions and 2 deletions.
  1. +2 −2 cake/libs/router.php
  2. +11 −0 cake/tests/cases/libs/router.test.php
View
@@ -1060,7 +1060,7 @@ function queryString($q, $extra = array(), $escape = false) {
* @access public
* @static
*/
- function reverse($params) {
+ function reverse($params, $full = false) {
$pass = $params['pass'];
$named = $params['named'];
$url = $params['url'];
@@ -1072,7 +1072,7 @@ function reverse($params) {
if (!empty($url)) {
$params['?'] = $url;
}
- return Router::url($params);
+ return Router::url($params, $full);
}
/**
@@ -2147,6 +2147,17 @@ function testRouterReverse() {
);
$result = Router::reverse($params);
$this->assertEqual($result, '/eng/posts/view/1?foo=bar&baz=quu');
+
+ $params = array(
+ 'lang' => 'eng',
+ 'controller' => 'posts',
+ 'action' => 'view',
+ 'pass' => array(1),
+ 'named' => array(),
+ 'url' => array('url' => 'eng/posts/view/1')
+ );
+ $result = Router::reverse($params, true);
+ $this->assertPattern('/^http(s)?:\/\//', $result);
}
}

0 comments on commit eb1e040

Please sign in to comment.