Skip to content

Commit 4882913

Browse files
committed
fix: Auto Routing (Improved) Default Method Fallback does not work with $translateUriToCamelCase
1 parent d54f613 commit 4882913

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

system/Router/AutoRouterImproved.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,15 @@ private function checkUriForMethod(string $method): void
519519
return;
520520
}
521521

522-
if (! in_array($method, get_class_methods($this->controller), true)) {
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 (
526+
method_exists($this->controller, $method)
527+
// We do not permit `controller/somemethod`, so check the exact method
528+
// name.
529+
&& ! in_array($method, get_class_methods($this->controller), true)
530+
) {
523531
throw new PageNotFoundException(
524532
'"' . $this->controller . '::' . $method . '()" is not found.'
525533
);

0 commit comments

Comments
 (0)