mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2901 from dhensby/director-test
Making Director::test() ignore URL Anchors
This commit is contained in:
commit
d1befdd37c
@ -244,6 +244,10 @@ class Director implements TemplateGlobalProvider {
|
||||
Config::inst()->update('Cookie', 'report_errors', false);
|
||||
Requirements::set_backend(new Requirements_Backend());
|
||||
|
||||
if (strpos($url, '#') !== false) {
|
||||
$url = substr($url, 0, strpos($url, '#'));
|
||||
}
|
||||
|
||||
// Handle absolute URLs
|
||||
if (parse_url($url, PHP_URL_HOST)) {
|
||||
$bits = parse_url($url);
|
||||
|
@ -345,6 +345,23 @@ class DirectorTest extends SapphireTest {
|
||||
$_SERVER = $origServer;
|
||||
}
|
||||
|
||||
public function testTestIgnoresHashes() {
|
||||
//test that hashes are ignored
|
||||
$url = "DirectorTestRequest_Controller/returnGetValue?somekey=key";
|
||||
$hash = "#test";
|
||||
$response = Director::test($url . $hash, null, null, null, null, null, null, $request);
|
||||
$this->assertFalse($response->isError());
|
||||
$this->assertEquals('key', $response->getBody());
|
||||
$this->assertEquals($request->getURL(true), $url);
|
||||
|
||||
//test encoded hashes are accepted
|
||||
$url = "DirectorTestRequest_Controller/returnGetValue?somekey=test%23key";
|
||||
$response = Director::test($url, null, null, null, null, null, null, $request);
|
||||
$this->assertFalse($response->isError());
|
||||
$this->assertEquals('test#key', $response->getBody());
|
||||
$this->assertEquals($request->getURL(true), $url);
|
||||
}
|
||||
|
||||
public function testRequestFilterInDirectorTest() {
|
||||
$filter = new TestRequestFilter;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user