Skip to content

Commit 63fe862

Browse files
committed
chore: retest implementation
1 parent 906f6ed commit 63fe862

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

app/core/Router.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,27 @@ class Router
1515
private static function formatUrl($url)
1616
{
1717
self::$isRouteTriggered = true;
18-
// Ensure consistent URL formatting
19-
$url = '/' . trim($url, '/');
20-
if ($url !== '/') {
21-
$url .= '/';
22-
}
2318

24-
return $url;
19+
return rtrim($url, '/') . '/';
2520
}
2621

2722
public static function get($url, $controller, $method)
2823
{
29-
$url = self::formatUrl($url);
24+
if ($url === '/') {
25+
$url = '';
26+
} else {
27+
$url = self::formatUrl($url);
28+
}
3029
self::$routes['GET'][$url] = ['controller' => $controller, 'method' => $method];
30+
3131
return new static;
3232
}
3333

3434
public static function post($url, $controller, $method)
3535
{
3636
$url = self::formatUrl($url);
3737
self::$routes['POST'][$url] = ['controller' => $controller, 'method' => $method];
38+
3839
return new static;
3940
}
4041

@@ -109,11 +110,6 @@ public static function dispatch($url, $requestType)
109110
$request = new Request();
110111
$request->capture();
111112

112-
// Normalize URL format for matching with routes
113-
$url = '/' . trim($url, '/');
114-
if ($url !== '/') {
115-
$url .= '/';
116-
}
117113

118114
$url = self::matchRoute($url, $requestType);
119115

0 commit comments

Comments
 (0)