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