diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-01 18:55:42 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-01 18:55:42 +0100 |
commit | d1097a1dc30f40c68bc4a5c89d3fadb295c55e56 (patch) | |
tree | bc5e12c402d1abb6b00e064161f76aa3bf543189 /system/core/Router.php | |
parent | 8161e57a1c038566ff28a6ba08c9b165079c9b75 (diff) |
Allow use of dashes in controller/method URI segments
Supersedes PR #642
Diffstat (limited to 'system/core/Router.php')
-rw-r--r-- | system/core/Router.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/system/core/Router.php b/system/core/Router.php index 87f3e9e63..89fb74f2f 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -190,6 +190,7 @@ class CI_Router { { show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.'); } + // Is the method being specified? if (strpos($this->default_controller, '/') !== FALSE) { @@ -268,9 +269,13 @@ class CI_Router { return $segments; } + $temp = str_replace('-', '_', $segments[0]); + // Does the requested controller exist in the root folder? - if (file_exists(APPPATH.'controllers/'.$segments[0].'.php')) + if (file_exists(APPPATH.'controllers/'.$temp.'.php')) { + $segments[0] = $temp; + empty($segments[1]) OR $segments[1] = str_replace('-', '_', $segments[1]); return $segments; } @@ -283,6 +288,9 @@ class CI_Router { if (count($segments) > 0) { + $segments[0] = str_replace('-', '_', $segments[0]); + empty($segments[1]) OR $segments[1] = str_replace('-', '_', $segments[1]); + // Does the requested controller exist in the sub-folder? if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php')) { |