Unverified Commit d7ab8310 authored by alexpott's avatar alexpott

Issue #2846770 by diqidoq, dorian.dirusso, marie.pinet, Thib, larowlan,...

Issue #2846770 by diqidoq, dorian.dirusso, marie.pinet, Thib, larowlan, Mile23, andypost: AdminRouteSubscriber incorrectly identifies paths such as /administration-position as admin paths
parent 3655e082
......@@ -17,7 +17,8 @@ class AdminRouteSubscriber extends RouteSubscriberBase {
*/
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection->all() as $route) {
if (strpos($route->getPath(), '/admin') === 0 && !$route->hasOption('_admin_route') && static::isHtmlRoute($route)) {
$path = $route->getPath();
if (($path == '/admin' || strpos($path, '/admin/') === 0) && !$route->hasOption('_admin_route') && static::isHtmlRoute($route)) {
$route->setOption('_admin_route', TRUE);
}
}
......
......@@ -38,6 +38,27 @@ public function providerTestAlterRoutes() {
new Route('/admin/foo'),
TRUE,
];
$data['admin only'] = [
new Route('/admin'),
TRUE,
];
$data['admin in part of a word'] = [
new Route('/administration/foo'),
NULL,
];
$data['admin in part of a word with admin_route option'] = [
(new Route('/administration/foo'))
->setOption('_admin_route', TRUE),
TRUE,
];
$data['admin not at the start of the path'] = [
new Route('/foo/admin/bar'),
NULL,
];
$data['admin in part of a word not at the start of the path'] = [
new Route('/foo/administration/bar'),
NULL,
];
$data['admin option'] = [
(new Route('/foo'))
->setOption('_admin_route', TRUE),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment