@@ -40,7 +40,7 @@ class Router
40
40
/**
41
41
* Router Version
42
42
*/
43
- const VERSION = '2.3.4 ' ;
43
+ const VERSION = '2.4.0 ' ;
44
44
45
45
/**
46
46
* @var string $baseFolder Pattern definitions for parameters of Route
@@ -326,14 +326,15 @@ public function run(): void
326
326
327
327
if ($ foundRoute === false ) {
328
328
if (!$ this ->errorCallback ) {
329
- $ this ->errorCallback = function () {
330
- $ this ->response ()
331
- ->setStatusCode (Response::HTTP_NOT_FOUND )
332
- ->sendHeaders ();
333
- return $ this ->exception ('Looks like page not found or something went wrong. Please try again. ' );
329
+ $ this ->errorCallback = function (Request $ request , Response $ response ) {
330
+ $ response ->setStatusCode (Response::HTTP_NOT_FOUND );
331
+ $ response ->setContent ('Looks like page not found or something went wrong. Please try again. ' );
332
+ return $ response ;
334
333
};
335
334
}
336
- call_user_func ($ this ->errorCallback );
335
+ $ this ->routerCommand ()->sendResponse (
336
+ call_user_func ($ this ->errorCallback , $ this ->request (), $ this ->response ())
337
+ );
337
338
}
338
339
}
339
340
@@ -790,6 +791,7 @@ protected function getRequestUri(): string
790
791
$ dirname = $ dirname === '/ ' ? '' : $ dirname ;
791
792
$ basename = basename ($ script );
792
793
$ uri = str_replace ([$ dirname , $ basename ], '' , $ this ->request ()->server ->get ('REQUEST_URI ' ));
794
+ $ uri = preg_replace ('/\/ ' .str_replace (['. ' ],['\. ' ], $ this ->baseFolder ).'/ ' , '' , $ uri , 1 );
793
795
return $ this ->clearRouteName (explode ('? ' , $ uri )[0 ]);
794
796
}
795
797
}
0 commit comments