@@ -52,6 +52,7 @@ public static function getPathExpression($url): mixed
5252 */
5353 public static function verify (): bool
5454 {
55+ // verify routes with explicit definition
5556 if (class_exists ('Leaf\App ' )) {
5657 if (
5758 in_array (
@@ -60,23 +61,30 @@ public static function verify(): bool
6061 return preg_replace ('/\/{(.*?)}/ ' , '/(.*?) ' , $ item );
6162 }, static ::$ config ['except ' ])
6263 )
63- ) {
64- return true ;
65- }
64+ ) { return true ; }
6665 } else {
6766 if (in_array (Request::getPathInfo (), static ::$ config ['except ' ])) {
6867 return true ;
6968 }
7069 }
70+
71+ // verify routes with pattern definitions
72+ $ pattern = static ::getPathExpression (Request::getPathInfo ());
73+ if (!is_null ($ pattern ) and in_array ($ pattern , static ::$ config ['except ' ])) {
74+ return true ;
75+ }
7176
7277 if (in_array (Request::getMethod (), static ::$ config ['methods ' ])) {
7378 $ requestData = Request::body ();
7479 $ requestHeaders = Request::headers ();
7580
81+ # TODO: check for csrf token in headers using regex matching the csrf token header pattern
7682 $ requestToken = $ requestData [static ::$ config ['secretKey ' ]]
7783 ?? $ requestHeaders [static ::$ config ['secretKey ' ]]
7884 ?? $ requestHeaders ['x-csrf-token ' ]
7985 ?? $ requestHeaders ['X-CSRF-TOKEN ' ]
86+ ?? $ requestHeaders ['X-CSRF-Token ' ]
87+ ?? $ requestHeaders ['X-Csrf-Token ' ]
8088 ?? null ;
8189
8290 if (!$ requestToken ) {
0 commit comments