traewelling icon indicating copy to clipboard operation
traewelling copied to clipboard

API v1 returns 404 when requesting departures from stations with slashes in their name

Open jeriox opened this issue 3 years ago • 1 comments
trafficstars

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:

  1. 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=)
  2. A 404 error is thrown
  3. 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=)
  4. A result is delivered with the corresponding departures

Expected behavior I expect the API to also deliver results for Stations with slashes

jeriox avatar May 24 '22 17:05 jeriox

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');

HerrLevin avatar Jun 29 '22 06:06 HerrLevin

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.

HerrLevin avatar Jan 07 '23 17:01 HerrLevin