1212use Statamic \Facades ;
1313use Statamic \Facades \Blink ;
1414use Statamic \Facades \CP \Nav ;
15+ use Statamic \Facades \URL ;
1516use Statamic \Facades \User ;
1617use Tests \FakesRoles ;
1718use Tests \PreventSavingStacheItemsToDisk ;
@@ -35,6 +36,13 @@ public function setUp(): void
3536 Facades \Form::shouldReceive ('all ' )->andReturn (collect ());
3637 }
3738
39+ public function tearDown (): void
40+ {
41+ URL ::enforceTrailingSlashes (false );
42+
43+ parent ::tearDown ();
44+ }
45+
3846 protected function resolveApplicationConfiguration ($ app )
3947 {
4048 parent ::resolveApplicationConfiguration ($ app );
@@ -408,6 +416,34 @@ public function it_resolves_extension_children_closure_and_can_check_when_parent
408416 $ this ->assertTrue ($ this ->getItemByDisplay ($ seoPro ->children (), 'Section Defaults ' )->isActive ());
409417 }
410418
419+ #[Test]
420+ public function it_properly_handles_is_active_checks_when_trailing_slashes_are_enforced ()
421+ {
422+ URL ::enforceTrailingSlashes ();
423+
424+ Nav::clearCachedUrls ();
425+
426+ $ parent = Nav::create ('parent ' )
427+ ->section ('test ' )
428+ ->url ('http://localhost/cp/parent ' )
429+ ->children ([
430+ $ hello = Nav::create ('hello ' )->url ('http://localhost/cp/hello ' ),
431+ $ world = Nav::create ('world ' )->url ('http://localhost/cp/world ' ),
432+ ]);
433+
434+ // Test active status with trailing slash in request URL
435+ Request::swap (Request::create ('http://localhost/cp/hello/ ' ));
436+ $ this ->assertTrue ($ parent ->isActive ());
437+ $ this ->assertTrue ($ hello ->isActive ());
438+ $ this ->assertFalse ($ world ->isActive ());
439+
440+ // Test active status on descendant with trailing slash
441+ Request::swap (Request::create ('http://localhost/cp/hello/nested/path/ ' ));
442+ $ this ->assertTrue ($ parent ->isActive ());
443+ $ this ->assertTrue ($ hello ->isActive ());
444+ $ this ->assertFalse ($ world ->isActive ());
445+ }
446+
411447 #[Test]
412448 public function it_properly_handles_various_edge_cases_when_checking_is_active_on_descendants_of_nav_children ()
413449 {
0 commit comments