From bdbc6a4828f6da50c641b8361423b8721b01a523 Mon Sep 17 00:00:00 2001 From: Lonnie Ezell Date: Tue, 26 Feb 2019 22:38:02 -0600 Subject: [PATCH] Fix routing when no default route has been specified. Fixes #1758 --- system/Router/Router.php | 5 +++-- .../source/tutorial/static_pages.rst | 20 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/system/Router/Router.php b/system/Router/Router.php index 953d06a2f8d2..ae674fc4c3e7 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -561,6 +561,8 @@ public function autoRoute(string $uri) */ protected function validateRequest(array $segments) { + $segments = array_filter($segments); + $c = count($segments); $directory_override = isset($this->directory); @@ -571,8 +573,7 @@ protected function validateRequest(array $segments) $test = $this->directory . ucfirst($this->translateURIDashes === true ? str_replace('-', '_', $segments[0]) : $segments[0] ); - if (! is_file(APPPATH . 'Controllers/' . $test . '.php') && $directory_override === false && is_dir(APPPATH . 'Controllers/' . $this->directory . ucfirst($segments[0])) - ) + if (! is_file(APPPATH . 'Controllers/' . $test . '.php') && $directory_override === false && is_dir(APPPATH . 'Controllers/' . $this->directory . ucfirst($segments[0]))) { $this->setDirectory(array_shift($segments), true); continue; diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst index 3e5926cf926f..ce81d16960ea 100644 --- a/user_guide_src/source/tutorial/static_pages.rst +++ b/user_guide_src/source/tutorial/static_pages.rst @@ -31,15 +31,15 @@ code. :: - setDefaultController('Pages/showme'); - Add the following line, **after** the route directive for '/'. :: @@ -236,4 +230,4 @@ method in the pages controller? Awesome! You should see something like the following: .. image:: ../images/tutorial1.png - :align: center \ No newline at end of file + :align: center