From d504f1d5bb987e47340a4ad69af2ca0d4059c099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Fri, 8 Nov 2024 12:21:54 +0100 Subject: [PATCH] encode and decode parameters in routes --- src/Routing/Route.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Routing/Route.php b/src/Routing/Route.php index 78c8ca9..a9a74cf 100644 --- a/src/Routing/Route.php +++ b/src/Routing/Route.php @@ -34,7 +34,7 @@ class Route implements IRoute foreach ($this->pattern as $fragment) { if (preg_match('/^{(\\w+)(\\?)?}$/', $fragment, $matches) === 1) { if (isset($parameters[$matches[1]])) { - $link[] = $parameters[$matches[1]]; + $link[] = rawurlencode($parameters[$matches[1]]); unset($parameters[$matches[1]]); } elseif (!isset($matches[2])) {//TODO: why? parameter not found but not optional $link[] = $fragment; @@ -64,7 +64,7 @@ class Route implements IRoute foreach ($path as $i => $fragment) { if (preg_match('/^{(\\w+)(?:\\?)?}$/', $this->pattern[$i], $matches) === 1) { - $parameters[$matches[1]] = $fragment; + $parameters[$matches[1]] = rawurldecode($fragment); } elseif ($fragment != $this->pattern[$i]) { return null; }