public function RouterTest::testLeadingSlashes in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testLeadingSlashes()
Ensure that multiple leading slashes are redirected.
File
- core/
modules/ system/ tests/ src/ Functional/ Routing/ RouterTest.php, line 329
Class
- RouterTest
- Functional class for the full integrated routing system.
Namespace
Drupal\Tests\system\Functional\RoutingCode
public function testLeadingSlashes() {
$request = $this->container
->get('request_stack')
->getCurrentRequest();
$url = $request
->getUriForPath('//router_test/test1');
$this
->drupalGet($url);
$this
->assertSession()
->addressEquals($request
->getUriForPath('/router_test/test1'));
// It should not matter how many leading slashes are used and query strings
// should be preserved.
$url = $request
->getUriForPath('/////////////////////////////////////////////////router_test/test1') . '?qs=test';
$this
->drupalGet($url);
$this
->assertSession()
->addressEquals($request
->getUriForPath('/router_test/test1') . '?qs=test');
// Ensure that external URLs in destination query params are not redirected
// to.
$url = $request
->getUriForPath('/////////////////////////////////////////////////router_test/test1') . '?qs=test&destination=http://www.example.com%5c@drupal8alt.test';
$this
->drupalGet($url);
$this
->assertSession()
->addressEquals($request
->getUriForPath('/router_test/test1') . '?qs=test');
}