Generate full url from Router::reverse() #45

Closed
wants to merge 1 commit into
from
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);
}
}