spiral/framework

[spiral/router] Issue with Registering Routes Containing Host using RoutesBootloader

butschster opened this issue · 0 comments

When using the RoutesBootloader to define routes that begin with a host (using //<host>), the RoutingConfigurator seems to trim the starting double slashes. This leads to the Router misunderstanding and registering the pattern as if it started from the path, not the host.

Steps to reproduce:

  1. Define a route using RoutesBootloader in the following manner:
protected function defineRoutes(RoutingConfigurator $routes): void
{
    $routes->add('register', "//<host>/register")
           ->callable(fn (string $host) => $host);
}
  1. Check how the route is registered in the Router.

Expected behavior:
The route should be registered as //<host>/register, indicating that the pattern starts with the host name.

Actual behavior:
The Router trims the starting double slashes and registers the route as <host>/register, causing it to misinterpret the route pattern.

Additional notes:
Using PHP attributes for route registration does not seem to exhibit this issue; it's specific to RoutesBootloader.