Skip to content

Commit 0d96fba

Browse files
committed
fix: Auto Routing (Improved) Default Method Fallback does not work with $translateUriToCamelCase
1 parent 29e5fab commit 0d96fba

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

system/Router/AutoRouterImproved.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,17 @@ private function checkUriForMethod(string $method): void
519519
return;
520520
}
521521

522-
if (! in_array($method, get_class_methods($this->controller), true)) {
523-
throw new PageNotFoundException(
524-
'"' . $this->controller . '::' . $method . '()" is not found.'
525-
);
522+
// If `getSomeMethod()` exists, only `controller/some-method` should be
523+
// accessible. But if a visitor navigates to `controller/somemethod`,
524+
// `getSomemethod()` will be checked, and method_exists() will return true.
525+
if (method_exists($this->controller, $method)) {
526+
// We do not permit `controller/somemethod`, so check the exact method
527+
// name.
528+
if (! in_array($method, get_class_methods($this->controller), true)) {
529+
throw new PageNotFoundException(
530+
'"' . $this->controller . '::' . $method . '()" is not found.'
531+
);
532+
}
526533
}
527534
}
528535

0 commit comments

Comments
 (0)