From 338c77594d64cfcab160d2da7911299c309163fc Mon Sep 17 00:00:00 2001 From: Sander A Date: Thu, 31 Jan 2019 03:26:38 +0200 Subject: [PATCH] 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" --- Route.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Route.php b/Route.php index dfd91ec..5495cee 100644 --- a/Route.php +++ b/Route.php @@ -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 = '/'; }