Merge pull request #45 from joeytrapp/router-reverse

Generate full url from Router::reverse(). Fixes #1638
This commit is contained in:
Mark Story 2011-05-10 17:43:29 -07:00
commit eb1e040ae9
2 changed files with 13 additions and 2 deletions

View file

@ -1060,7 +1060,7 @@ class Router {
* @access public
* @static
*/
function reverse($params) {
function reverse($params, $full = false) {
$pass = $params['pass'];
$named = $params['named'];
$url = $params['url'];
@ -1072,7 +1072,7 @@ class Router {
if (!empty($url)) {
$params['?'] = $url;
}
return Router::url($params);
return Router::url($params, $full);
}
/**

View file

@ -2147,6 +2147,17 @@ class RouterTest extends CakeTestCase {
);
$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);
}
}