added test for unique subdir setup in request

pull/501/head
n0nag0n 1 year ago
parent 5456cdca1e
commit 0d026b16d1

@ -177,6 +177,9 @@ final class Request
}
// Get the requested URL without the base directory
// This rewrites the url in case the public url and base directories match
// (such as installing on a subdirectory in a web server)
// @see testInitUrlSameAsBaseDirectory
if ('/' !== $this->base && '' !== $this->base && 0 === strpos($this->url, $this->base)) {
$this->url = substr($this->url, \strlen($this->base));
}

@ -7,6 +7,7 @@
*/
use flight\net\Request;
use flight\util\Collection;
class RequestTest extends PHPUnit\Framework\TestCase
{
@ -154,4 +155,14 @@ class RequestTest extends PHPUnit\Framework\TestCase
$request = new Request();
self::assertEquals('http', $request->scheme);
}
public function testInitUrlSameAsBaseDirectory() {
$request = new Request([
'url' => '/vagrant/public/flightphp',
'base' => '/vagrant/public',
'query' => new Collection(),
'type' => ''
]);
$this->assertEquals('/flightphp', $request->url);
}
}

Loading…
Cancel
Save