traewelling
traewelling copied to clipboard
API v1 returns 404 when requesting departures from stations with slashes in their name
Describe the bug When requesting the Departures of a station that contains slashes in its name via the v1 API, a 404 error is thrown. Replacing the slashes with spaces resolves the issue.
To Reproduce Steps to reproduce the behavior:
- Request departures for a station with a slash in its name, e.g. "Luisenplatz-Süd/Park Sanssouci, Potsdam" (
https://beta.traewelling.de/api/v1/trains/station/Luisenplatz-S%C3%BCd%2FPark%20Sanssouci,%20Potsdam/departures?when=2022-05-24T16:58:05.077869Z&travelType=) - A 404 error is thrown
- Request the departures with spaces instead of slashes (
https://beta.traewelling.de/api/v1/trains/station/Luisenplatz-S%C3%BCd%20Park%20Sanssouci,%20Potsdam/departures?when=2022-05-24T16:58:05.077869Z&travelType=) - A result is delivered with the corresponding departures
Expected behavior I expect the API to also deliver results for Stations with slashes
Laravel does not support slashes in URL parameters and there are multiple issues to that wherein they explain that they won't fix this. (e.g. https://github.com/laravel/framework/issues/22125)
There seems to be a workaround (https://github.com/laravel/framework/issues/22125#issuecomment-880786978) but this will break if there are more than one slashes in the url. In my opinion, a space instead of a slash would be the more consistent option but this needs to be documented.
// Origin Route
Route::get('/{query}', [\App\Http\Controllers\Front\User\CategoryController::class, 'category'])->name('category');
// Extra Route on the end of the route file:
Route::get('/{query}/{more?}', [\App\Http\Controllers\Front\User\CategoryController::class, 'category'])->name('category');
We were not able to fix this issue since it's the intended behavior of laravel. We've documented this in the API docs (https://traewelling.de/api/documentation#/Checkin/getDepartures) so I'll close this issue.