Skip to content

Commit dae7f2d

Browse files
authored
Merge pull request #16 from BespredeL/fix/laravel-route-matching
fix: check both route name and path using Laravel methods
2 parents ac8eebe + f6bd689 commit dae7f2d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Middleware/RestrictAccessByGeo.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,16 @@ protected function shouldApply(Request $request): bool
9494
{
9595
$only = Config::get('geo-restrict.routes.only', []);
9696
$except = Config::get('geo-restrict.routes.except', []);
97-
$current = $request->route()?->getName() ?? $request->path();
9897

9998
foreach ($except as $pattern) {
100-
if (fnmatch($pattern, $current)) {
99+
if ($request->routeIs($pattern) || $request->is($pattern)) {
101100
return false;
102101
}
103102
}
104103

105104
if (!empty($only)) {
106105
foreach ($only as $pattern) {
107-
if (fnmatch($pattern, $current)) {
106+
if ($request->routeIs($pattern) || $request->is($pattern)) {
108107
return true;
109108
}
110109
}

0 commit comments

Comments
 (0)