core/Route.php
private static function parseUrl(string $url)
    {
        if ('/favicon.ico' == $url) {
            exit;
        }
        $url_temp = parse_url($url);
        $url = $url_temp['path'];
        if (preg_match('@\.json$@i', $url)) {
            $_SERVER['REQUEST_AJAX'] = true;
            $url = preg_replace('@\.json$@i', '', $url);
        }
        $iData = self::matchUrl($url);

        if ($iData == null) {
            return null;
        }
        //路由路径
        $uri = empty($iData['uri']) ? '/' : $iData['uri'];
        $name = $iData['name'];
        $arg = [
            'app' => $name,
            'base' => $iData['base'],
            'ctl' => '',
            'act' => '',
        ];
        if (!isset($iData['rules']) || !is_array($iData['rules'])) {
            return null;
        }
        foreach ($iData['rules'] as $preg => $item) {
            if (preg_match($preg, $uri, $m)) {
                if (!is_array($item)) {
                    continue;
                }
                foreach ($item as $key => $val) {
                    $temp = null;
                    if (is_string($val)) {
                        $temp = preg_replace_callback('@\$(\d+)@', function ($m2) use ($m) {
                            return isset($m[$m2[1]]) ? $m[$m2[1]] : '';
                        }, $val);
                    } elseif (is_array($val)) {
                        $temp = preg_replace_callback('@\$(\d+)@', function ($m2) use ($m, $val) {
                            return isset($m[$m2[1]]) ? $m[$m2[1]] : $val['def'];
                        }, $val['map']);
                    } else {
                        continue;
                    }
                    $arg[$key] = $temp;
                }
                break;
            }
        }
        if (empty($arg['ctl'])) {
            return null;
        }
        $arg['ctl'] = strtolower($arg['ctl']);
        $arg['act'] = strtolower($arg['act']);
        foreach ($arg as $key => $val) {
            if (in_array($key, ['act', 'ctl', 'base', 'app'])) {
                continue;
            }
            if (!isset($_GET[$key])) {
                $_GET[$key] = $val;
            }
            if (!isset($_REQUEST[$key])) {
                $_REQUEST[$key] = $val;
            }
        }
        self::$route = $arg;
        return $arg;
    }
private static function parseUrl(string $url)
    {
        if ('/favicon.ico' == $url) {
            exit;
        }
        $url_temp = parse_url($url);
        $url = $url_temp['path'];
        if (preg_match('@\.json$@i', $url)) {
            $_SERVER['REQUEST_AJAX'] = true;
            $url = preg_replace('@\.json$@i', '', $url);
        }
        $iData = self::matchUrl($url);

        if ($iData == null) {
            return null;
        }
        //路由路径
        $uri = empty($iData['uri']) ? '/' : $iData['uri'];
        $name = $iData['name'];
        $arg = [
            'app' => $name,
            'base' => $iData['base'],
            'ctl' => '',
            'act' => '',
        ];
        if (!isset($iData['rules']) || !is_array($iData['rules'])) {
            return null;
        }
        foreach ($iData['rules'] as $preg => $item) {
            if (preg_match($preg, $uri, $m)) {
                if (!is_array($item)) {
                    continue;
                }
                foreach ($item as $key => $val) {
                    $temp = null;
                    if (is_string($val)) {
                        $temp = preg_replace_callback('@\$(\d+)@', function ($m2) use ($m) {
                            return isset($m[$m2[1]]) ? $m[$m2[1]] : '';
                        }, $val);
                    } elseif (is_array($val)) {
                        $temp = preg_replace_callback('@\$(\d+)@', function ($m2) use ($m, $val) {
                            return isset($m[$m2[1]]) ? $m[$m2[1]] : $val['def'];
                        }, $val['map']);
                    } else {
                        continue;
                    }
                    $arg[$key] = $temp;
                }
                break;
            }
        }
        if (empty($arg['ctl'])) {
            return null;
        }
        $arg['ctl'] = strtolower($arg['ctl']);
        $arg['act'] = strtolower($arg['act']);
        foreach ($arg as $key => $val) {
            if (in_array($key, ['act', 'ctl', 'base', 'app'])) {
                continue;
            }
            if (!isset($_GET[$key])) {
                $_GET[$key] = $val;
            }
            if (!isset($_REQUEST[$key])) {
                $_REQUEST[$key] = $val;
            }
        }
        self::$route = $arg;
        return $arg;
    }
解析URL路径
@param string $url
@return array|null