From 85f6ec1bc8f094e769835e9836b9fab7fb9e6ace Mon Sep 17 00:00:00 2001
From: filippo.bertilotti <filippobertilotti@gmail.com>
Date: Thu, 23 May 2024 11:18:21 +0200
Subject: [PATCH] output dei valori giĆ  esistenti per modificarli nella pagina edit (parte 134)

---
 src/Framework/router.php |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/Framework/router.php b/src/Framework/router.php
index 19a88d4..63596c4 100644
--- a/src/Framework/router.php
+++ b/src/Framework/router.php
@@ -12,8 +12,9 @@
 
 
     }
-    public function match (string $path,): array|bool {
-
+    public function match (string $path): array|bool {
+        $path = urldecode($path);
+        
         $path = trim($path, "/");   
 
         foreach ($this->routes as $route) {
@@ -40,11 +41,14 @@
         $segments = array_map(function(string $segment) :string {
 
             if(preg_match("#^\{([a-z][a-z0-9]*)\}$#", $segment, $matches)) {
-                $segment = "(?<" . $matches[1] . ">[a-z]+)";
+                return "(?<" . $matches[1] . ">[^/]*)";
+            }
+            if(preg_match("#^\{([a-z][a-z0-9]*):(.+)\}$#", $segment, $matches)) {
+                return "(?<" . $matches[1] . ">". $matches[2] ."[^/]*)";
             }
             return $segment;
         }, $segments);
 
-        return "#^" . implode("/", $segments) . "$#";
+        return "#^" . implode("/", $segments) . "$#iu";
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0