3.15.2 breaks my routing
Hi,
After upgrading from 3.15.1 to 3.15.2 my routing stopped working.
This request:
https://api.golfana.local:444/api/initialize-session (as taken from the network tab in the browser's developer console)
Is reported by \Flight::request()->url as: //api/initialize-session (note the double slash)
That double slash was already there in 3.15.1, I have no idea why.
I checked the change log for 3.15.2 and the part that breaks my code is:
$this->pattern = str_replace('//', '/', $pattern); in Route.php
I changed my routing accordingly from:
public function __invoke() : void
{
$this->logger->notice(sprintf('Invoking the router for [[%s]]', \Flight::request()->url));
$this->flight->route('POST //api/initialize-session', function() {(new InitializeSessionController())();});
to:
public function __invoke() : void
{
$this->logger->notice(sprintf('Invoking the router for [[%s]]', \Flight::request()->url));
$this->flight->route('POST /api/initialize-session', function() {(new InitializeSessionController())();});
but to no avail. The log output on both 3.15.1 and 3.15.2 is:
2025-05-28T22:14:46+00:00 node3.golfana.local golfana[2498]: golfana.NOTICE: Invoking the router for [[//api/initialize-session]] [] {"url":"//api/initialize-session","ip":"10.12.74.50","http_method":"POST","server":"10.12.74.80","referrer":"https://dev.golfana.local:9000/","user_agent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0","request_time_float":1748470486.787113,"file":"/mnt/GIT/backend/src/Router.php","line":260,"class":"App\Router","callType":"->","function":"__invoke"}
Did I miss something?
Ok sorry for the late response. I haven't had as much time as I used to to work on Flight 😅
So the change that was introduced was this https://github.com/flightphp/core/issues/637. Basically like you found it corrected duplicate // that could have been defined in a route. In RFC 3986 while it doesn't necessarily say, "Please don't put // in your URL" it does ask that all webservers normalize // down to /. In this situation given that the Router part of Flight is sorta becoming the server by handling the request itself, it should normalize it down to /.
The question I really have though is why are you defining routes with // in them and why are you passing // in your URLs? Is there a specific reason or it's just part of a complex legacy app?