Skip to content
Snippets Groups Projects
Unverified Commit 2882e26c authored by Alex Pott's avatar Alex Pott
Browse files

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

(cherry picked from commit d7ab8310)
parent 670f1626
Branches
Tags
No related merge requests found
......@@ -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),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment