Redirects should always consider the base directory.

pull/135/head
Mike Cao 11 years ago
parent eefcd2b55a
commit c0fa0bed7c

@ -1 +1 @@
1.1.11
1.1.12

@ -409,9 +409,9 @@ class Engine {
$base = $this->request()->base;
}
// Append base to relative urls
if ($base != '/' && $url[0] != '/' && strpos($url, '://') === false) {
$url = $base.'/'.$url;
// Append base url to redirect url
if ($base != '/' && strpos($url, '://') === false) {
$url = preg_replace('#/+#', '/', $base.'/'.$url);
}
$this->response(false)

@ -17,8 +17,8 @@ class RedirectTest extends PHPUnit_Framework_TestCase
private $app;
function getBaseUrl($base, $url){
if ($base != '/' && $url[0] != '/' && strpos($url, '://') === false) {
return $base.'/'.$url;
if ($base != '/' && strpos($url, '://') === false) {
$url = preg_replace('#/+#', '/', $base.'/'.$url);
}
return $url;
@ -38,12 +38,12 @@ class RedirectTest extends PHPUnit_Framework_TestCase
$this->assertEquals('/subdir', $base);
}
// Absolute URLs should ignore the base
// Absolute URLs should include the base
function testAbsoluteUrl(){
$url = '/login';
$base = $this->app->request()->base;
$this->assertEquals('/login', $this->getBaseUrl($base, $url));
$this->assertEquals('/subdir/login', $this->getBaseUrl($base, $url));
}
// Relative URLs should include the base

Loading…
Cancel
Save