From 6020e9f50238d9a4a5709214c5aa7f8f2dc99c2e Mon Sep 17 00:00:00 2001 From: SherifAbdlNaby Date: Thu, 1 Mar 2018 14:49:19 +0200 Subject: [PATCH] Normalize for case-sensitive server environments normalize route/controller/action after parsing uri to work as expected in case-sensitive server environments. --- Controllers/Web/AccountController.php | 10 +++++----- Core/Router.php | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Controllers/Web/AccountController.php b/Controllers/Web/AccountController.php index fd83e4e..45b1f6d 100644 --- a/Controllers/Web/AccountController.php +++ b/Controllers/Web/AccountController.php @@ -12,11 +12,11 @@ class AccountController extends WebController { - public function index(){ + public function Index(){ return $this->renderFullError('Not Found', 404); } - public function login(){ + public function Login(){ if($_SERVER['REQUEST_METHOD'] == 'POST') { //LOGIN if(LoginService::login($_POST['username'], $_POST['password'])) @@ -37,7 +37,7 @@ public function login(){ } } - public function register(){ + public function Register(){ if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (RegisterService::Register($_POST['name'], $_POST['username'], $_POST['password'], $_POST['confirmPassword'], $_POST['email'])) return $this->redirect('/'); @@ -49,14 +49,14 @@ public function register(){ return $this->render(); } - public function logout(){ + public function Logout(){ Session::destroyLoginSession(); if(!empty($_GET['returnUrl'])) return $this->redirect($_GET['returnUrl']); return $this->redirect('/'); } - public function view($username){ + public function View($username){ $userRepository = new UserRepository(); diff --git a/Core/Router.php b/Core/Router.php index d931b18..2c76531 100644 --- a/Core/Router.php +++ b/Core/Router.php @@ -79,6 +79,11 @@ public function __construct(&$uri) //Get Params $this->params = $path_parts; } + + //normalize route/controller/action to the expected case + $this->route = ucfirst(strtolower($this->route)); + $this->controller = ucfirst(strtolower($this->controller)); + $this->action = ucfirst(strtolower($this->action)); } /**