From 337b1b08b5949812aa9f1e89b8556190b099fc45 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 23 Nov 2013 23:22:58 -0500 Subject: [PATCH] Fixes #1298: supporting route with trailing slash. --- framework/yii/base/Module.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/yii/base/Module.php b/framework/yii/base/Module.php index 3ca3aa2..1dd243e 100644 --- a/framework/yii/base/Module.php +++ b/framework/yii/base/Module.php @@ -586,7 +586,8 @@ abstract class Module extends Component Yii::$app->controller = $oldController; return $result; } else { - throw new InvalidRouteException('Unable to resolve the request "' . trim($this->getUniqueId() . '/' . $route, '/') . '".'); + $id = $this->getUniqueId(); + throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".'); } } @@ -608,9 +609,8 @@ abstract class Module extends Component if ($route === '') { $route = $this->defaultRoute; } - if (($pos = strpos($route, '/')) !== false) { - $id = substr($route, 0, $pos); - $route = substr($route, $pos + 1); + if (strpos($route, '/') !== false) { + list ($id, $route) = explode('/', $route, 2); } else { $id = $route; $route = '';