diff --git a/core/core.php b/core/core.php index e08d3c4..d8b3679 100644 --- a/core/core.php +++ b/core/core.php @@ -1,6 +1,6 @@ getCode(); } else { $target = trim(explode("\n", $route["target"])[0]); + $extra = $route["extra"] ?? ""; $pattern = str_replace("/","\\/", $route["request"]); - $pattern = "/$pattern/"; + $pattern = "/$pattern/i"; if (!startsWith($requestedUri, '/')) { $requestedUri = "/$requestedUri"; } @@ -122,6 +123,7 @@ if(isset($_GET["api"]) && is_string($_GET["api"])) { if (is_array($match) && !empty($match)) { foreach($match as $index => $value) { $target = str_replace("$$index", $value, $target); + $extra = str_replace("$$index", $value, $extra); } } @@ -139,7 +141,7 @@ if(isset($_GET["api"]) && is_string($_GET["api"])) { $response = serveStatic($currentDir, $target); break; case "dynamic": - $view = $route["extra"] ?? ""; + $view = parseClass($extra); $file = getClassPath($target); if(!file_exists($file) || !is_subclass_of($target, Document::class)) { $document = new Document404($user, $view); diff --git a/js/script.js b/js/script.js index 9fb48a0..02f00c9 100644 --- a/js/script.js +++ b/js/script.js @@ -9,7 +9,7 @@ let Core = function () { params = typeof params !== 'undefined' ? params : {}; callback = typeof callback !== 'undefined' ? callback : function (data) {}; - const path = '/api/' + (func.startsWith('/') ? '' : '/') + func; + const path = '/api' + (func.startsWith('/') ? '' : '/') + func; $.post(path, params, function (data) { console.log(func + "(): success=" + data.success + " msg=" + data.msg); callback.call(this, data);