修正Url类

This commit is contained in:
thinkphp
2016-06-17 12:22:47 +08:00
parent a0f1a7f436
commit 0955eb18e1
2 changed files with 4 additions and 3 deletions

View File

@@ -515,7 +515,7 @@ class Route
if ($method) {
return self::$rules[$method];
} else {
return self::$rules['*'] + self::$rules['GET'] + self::$rules['POST'] + self::$rules['PUT'] + self::$rules['DELETE'];
return array_merge_recursive(self::$rules['*'], self::$rules['GET'], self::$rules['POST'], self::$rules['PUT'], self::$rules['DELETE']);
}
}

View File

@@ -141,7 +141,7 @@ class Url
} else {
$path = explode('/', $url);
$action = array_pop($path);
$controller = empty($path) ? $controller : (Config::get('url_controller_convert') ? Loader::parseName(array_pop($path)) : array_pop($path));
$controller = empty($path) ? $controller : (Config::get('url_convert') ? Loader::parseName(array_pop($path)) : array_pop($path));
$module = empty($path) ? $module : array_pop($path) . '/';
$url = $module . $controller . '/' . $action;
}
@@ -242,6 +242,7 @@ class Url
}
// 检查变量匹配
$array = $vars;
$match = false;
if ($pattern && self::pattern($pattern, $vars)) {
foreach ($pattern as $key => $val) {
if (isset($vars[$key])) {
@@ -256,7 +257,7 @@ class Url
if (empty($pattern) && empty($param)) {
// 没有任何变量
return $url;
} elseif (!empty($match) || (!empty($param) && array_intersect_assoc($param, $array) == $param)) {
} elseif ($match && (empty($param) || array_intersect_assoc($param, $array) == $param)) {
// 存在变量定义
$vars = array_diff_key($array, $param);
return $url;