Repository: EasyCorp/EasyAdminBundle (language: php)

Issue:
MenuItemMatcher doMarkSelectedPrettyUrlsMenuItem is broken
**Describe the bug**

There is an issue when computing the selected menu items for create and edit urls with the new Pretty urls system (for example : `/admin/foo/{id}/edit`

See : 
https://github.com/EasyCorp/EasyAdminBundle/blob/f2fc65b99903d0dbba08261026305ecb63c97a34/src/Menu/MenuItemMatcher.php#L185-L192

On my side when I remove `$currentRequestUriWithoutAction .= '/';` it fixes the issue.
So I don't really understand why we are adding this trailing slash, maybe my router is not configured in the same way and rewrites url to alway remove trailing slash.

I think the safest way to handle both cases should be to always remove or append the trailing slash on compared values.
 
**To Reproduce**
- Create an entity and the corresponding crud controller
- Create a dashboard controller and add the linkToCrud to configureMenuItems
- Visite the create or edit page of an entity item

**(OPTIONAL) Additional context**
Thanks in advance !



Discussion / hints:

Fix patch:
diff --git a/src/Menu/MenuItemMatcher.php b/src/Menu/MenuItemMatcher.php
index 326bd5f669..3ef634abc3 100644
--- a/src/Menu/MenuItemMatcher.php
+++ b/src/Menu/MenuItemMatcher.php
@@ -189,7 +189,6 @@ private function doMarkSelectedPrettyUrlsMenuItem(array $menuItems, Request $req
         if (str_ends_with($currentRequestUriWithoutQueryString, '/edit')) {
             $currentRequestUriWithoutAction = preg_replace('#/[^/]+$#', '', $currentRequestUriWithoutAction);
         }
-        $currentRequestUriWithoutAction .= '/';
 
         foreach ($menuItems as $menuItemDto) {
             if ($menuItemDto->isMenuSection()) {


Test patch:
diff --git a/tests/Controller/PrettyUrls/PrettyUrlsControllerTest.php b/tests/Controller/PrettyUrls/PrettyUrlsControllerTest.php
index 5e96892b1f..2fac6f4219 100644
--- a/tests/Controller/PrettyUrls/PrettyUrlsControllerTest.php
+++ b/tests/Controller/PrettyUrls/PrettyUrlsControllerTest.php
@@ -146,6 +146,19 @@ public function testCustomMainMenuUsesPrettyUrls()
         $this->assertSame('http://localhost/second/dashboard/user-editor/custom/path-for-index', $crawler->filter('li.menu-item a:contains("Users")')->attr('href'));
     }
 
+    /**
+     * @dataProvider provideActiveMenuUrls
+     */
+    public function testMainMenuActiveItemWithPrettyUrls(string $url)
+    {
+        $client = static::createClient();
+        $client->followRedirects();
+
+        $crawler = $client->request('GET', $url);
+
+        $this->assertSame('Categories', trim($crawler->filter('.menu-item.active')->text()));
+    }
+
     public function testDefaultActionsUsePrettyUrls()
     {
         $client = static::createClient();
@@ -212,6 +225,14 @@ public function testCustomSortLinksUsePrettyUrls()
         $this->assertSame('http://localhost/second/dashboard/user-editor/custom/path-for-index?page=1&sort%5Bemail%5D=DESC', $crawler->filter('th.searchable a')->eq(2)->attr('href'));
     }
 
+    public static function provideActiveMenuUrls(): iterable
+    {
+        yield ['/admin/pretty/urls/category'];
+        yield ['/admin/pretty/urls/category/new'];
+        yield ['/admin/pretty/urls/category/1'];
+        yield ['/admin/pretty/urls/category/1/edit'];
+    }
+
     public static function provideDefaultPageUrls(): iterable
     {
         yield 'Create' => ['/admin/pretty/urls/category/new'];