make nested router slugs work

This commit is contained in:
uwaa 2024-11-14 02:39:12 +00:00
parent 5447f37cea
commit b12616420b

View file

@ -13,16 +13,16 @@ public class Router : RouterBase
public override HttpMethod Method => HttpMethod.Any;
public override int Arguments => 1;
public override int Arguments => 0;
protected override async Task<HttpResponse?> GetResponseInner(HttpRequest req, ArraySegment<string> path)
{
string next = path[0];
string next = path.Count == 0 ? string.Empty : path[0];
foreach (Route route in Routes)
{
if (route.Key == next || route.Key == null)
{
HttpResponse? resp = await route.Router.GetResponse(req, route.Key == null ? path : path[1..]);
HttpResponse? resp = await route.Router.GetResponse(req, route.Key == null || path.Count == 0 ? path : path[1..]);
if (resp != null)
return resp;
}