From c0a321fae9252bc92e594cb91ab917e291c013e3 Mon Sep 17 00:00:00 2001 From: lamtranb Date: Sat, 12 Aug 2023 18:00:44 +0700 Subject: [PATCH] fix empty route matching single pattern --- src/Active.php | 4 ++-- tests/ActiveTest.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Active.php b/src/Active.php index 6cce521..f46db42 100644 --- a/src/Active.php +++ b/src/Active.php @@ -218,7 +218,7 @@ public function checkRoute($routeNames) * * @return bool */ - public function checkRoutePattern($patterns) + public function checkRoutePattern($patterns): bool { if (!$this->route) { return false; @@ -227,7 +227,7 @@ public function checkRoutePattern($patterns) $routeName = $this->route->getName(); if ($routeName == null) { - return in_array(null, $patterns); + return in_array(null, (array) $patterns); } foreach ((array)$patterns as $p) { diff --git a/tests/ActiveTest.php b/tests/ActiveTest.php index 34ad56b..2b105a1 100644 --- a/tests/ActiveTest.php +++ b/tests/ActiveTest.php @@ -421,6 +421,11 @@ public function provideCheckRoutePatternTestData() ['foo.*', null], true, ], + 'route with no name and single pattern' => [ + Request::create('/'), + 'foo.*', + false, + ], ]; }