From e4bc62da730067f71176784114b8a828f888470e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 10 Aug 2011 22:45:19 -0500 Subject: [PATCH] fix bug in route loader causing requests for specific formats to not be returned correctly. --- system/routing/loader.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/system/routing/loader.php b/system/routing/loader.php index 43414cc2..55e426e1 100644 --- a/system/routing/loader.php +++ b/system/routing/loader.php @@ -50,6 +50,16 @@ class Loader { */ private function load_nested_routes($segments) { + // If the request URI only more than one segment, and the last segment contains a dot, we will + // assume the request is for a specific format (users.json or users.xml) and strip off + // everything after the dot so we can load the appropriate file. + if (count($segments) > 0 and strpos(end($segments), '.') !== false) + { + $segment = array_pop($segments); + + array_push($segments, substr($segment, 0, strpos($segment, '.'))); + } + // Work backwards through the URI segments until we find the deepest possible // matching route directory. Once we find it, we will return those routes. foreach (array_reverse($segments, true) as $key => $value)