Skip to content

Commit 227e5ed

Browse files
author
Splashsky
committed
🧼 Clean up request handling by treating basePath similar to other routes
1 parent 3dd5ddc commit 227e5ed

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/Splashsky/Router.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private static function tokenize(string $uri)
188188
*/
189189
public static function run(string $basePath = '', bool $multimatch = false)
190190
{
191-
$basePath = rtrim($basePath, '/');
191+
$basePath = self::trimRoute($basePath);
192192
$method = $_SERVER['REQUEST_METHOD'];
193193
$uri = parse_url($_SERVER['REQUEST_URI'])['path'];
194194
$path = urldecode(self::trimRoute($uri));
@@ -198,7 +198,8 @@ public static function run(string $basePath = '', bool $multimatch = false)
198198

199199
// Begin looking through routes
200200
foreach (self::$routes as $route) {
201-
if ($basePath != '' && $basePath != '/') {
201+
// If the basePath isn't just "root"
202+
if ($basePath != '/') {
202203
$route['route'] = $basePath.$route['route'];
203204
}
204205

0 commit comments

Comments
 (0)