Remove trailing slash from routes

Remove trailing slash from route (unless it's the root slash) before matching against routes. This ensures that both "/events" and "/events/" are matched with the route "/events"
This commit is contained in:
Sander A 2019-01-31 03:26:38 +02:00 committed by GitHub
parent 26683559b4
commit 338c77594d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,8 +27,8 @@ class Route{
// Parse current url
$parsed_url = parse_url($_SERVER['REQUEST_URI']);//Parse Uri
if(isset($parsed_url['path'])){
$path = $parsed_url['path'];
if(isset($parsed_url['path']) && $parsed_url['path'] != '/'){
$path = rtrim($parsed_url['path'], '/');
}else{
$path = '/';
}