aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Url.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Minz/Url.php')
-rw-r--r--lib/Minz/Url.php14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php
index 3948414d8..811f0fff7 100644
--- a/lib/Minz/Url.php
+++ b/lib/Minz/Url.php
@@ -145,10 +145,16 @@ class Minz_Url {
* @return array{c?:string,a?:string,params?:array<string,string>} URL representation
*/
public static function build(): array {
+ $get = [];
+ foreach ($_GET as $key => $value) {
+ if (is_string($key) && is_string($value)) {
+ $get[$key] = $value;
+ }
+ }
$url = [
- 'c' => $_GET['c'] ?? Minz_Request::defaultControllerName(),
- 'a' => $_GET['a'] ?? Minz_Request::defaultActionName(),
- 'params' => $_GET,
+ 'c' => is_string($_GET['c'] ?? null) ? $_GET['c'] : Minz_Request::defaultControllerName(),
+ 'a' => is_string($_GET['a'] ?? null) ? $_GET['a'] : Minz_Request::defaultActionName(),
+ 'params' => $get,
];
// post-traitement
@@ -166,7 +172,7 @@ function _url(string $controller, string $action, int|string ...$args): string|f
return false;
}
- $params = array ();
+ $params = [];
for ($i = 0; $i < $nb_args; $i += 2) {
$arg = '' . $args[$i];
$params[$arg] = '' . $args[$i + 1];