Browse Source

Added checking for the url parts.

Brian French 8 years ago
parent
commit
9fb4d6e1cd
1 changed files with 10 additions and 11 deletions
  1. 10 11
      src/Routing/RouteBuilder.php

+ 10 - 11
src/Routing/RouteBuilder.php

@@ -747,28 +747,27 @@ class RouteBuilder
         if (preg_match($regex, $defaults, $matches)) {
             unset($matches[0]);
             $matches = array_filter($matches, function ($value) {
-                return $value !== '' && $value !== '::';
+                return $value !== '::';
             });
-
             // Intentionally incomplete switch
             switch (count($matches)) {
                 case 2:
                     return [
-                        'controller' => $matches[3],
-                        'action' => $matches[4]
+                        'controller' => (isset($matches[3] ? $matches[3] : null),
+                        'action' => (isset($matches[4] ? $matches[4] : null)
                     ];
                 case 3:
                     return [
-                        'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : false),
-                        'controller' => $matches[3],
-                        'action' => $matches[4]
+                        'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : null),
+                        'controller' => (isset($matches[3] ? $matches[3] : null),
+                        'action' => (isset($matches[4] ? $matches[4] : null)
                     ];
                 case 4:
                     return [
-                        'plugin' => $matches[1],
-                        'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : false),
-                        'controller' => $matches[3],
-                        'action' => $matches[4]
+                        'plugin' => (isset($matches[1] ? $matches[1] : null),
+                        'prefix' => (isset($matches[2]) ? strtolower($matches[2]) : null),
+                        'controller' => (isset($matches[3] ? $matches[3] : null),
+                        'action' => (isset($matches[4] ? $matches[4] : null)
                     ];
             }
         }