From 9fb39fb8e5808d598953b1e8f028699ddddbb359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvis=20L=C4=81cis?= Date: Sun, 26 Jun 2022 15:17:06 +0300 Subject: [PATCH 1/3] Added additional test case for UrlGenerator class --- tests/Router/UrlGeneratorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Router/UrlGeneratorTest.php b/tests/Router/UrlGeneratorTest.php index ada08285b..45b76f333 100644 --- a/tests/Router/UrlGeneratorTest.php +++ b/tests/Router/UrlGeneratorTest.php @@ -516,9 +516,11 @@ public function testQueryArgsArrayMatchLaravel() $checkUrlsOnBoth = [ // Non url-encoded 'https://www.example.com/path?array[]=v1&array[]=v2', + 'https://www.example.com/path?array[0]=v1&array[1]=v2', // Already url-encoded 'https://www.example.com/path?array%5B%5D=v1&array%5B%5D=v2', + 'https://www.example.com/path?array%5B0%5D=v1&array%5B1%5D=v2', ]; foreach ($checkUrlsOnBoth as $url) { From 5be073cf1bda7638693a609de4b734080e5579ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvis=20L=C4=81cis?= Date: Sun, 26 Jun 2022 18:07:40 +0300 Subject: [PATCH 2/3] Changes in array key processing --- src/Router/UrlGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Router/UrlGenerator.php b/src/Router/UrlGenerator.php index 5c6f4a847..7268b4637 100644 --- a/src/Router/UrlGenerator.php +++ b/src/Router/UrlGenerator.php @@ -326,7 +326,7 @@ public static function buildStr(array $query, string $prefix = '', $argSeparator if ($i === $k) { if ($prefix) { // Make sure the key is setup for array values - if (Str::endsWith($prefix, '[]')) { + if (Str::endsWith($prefix, ']')) { $key = $prefix; } else { $key = "{$prefix}[]"; From f329c19f28dedce3b79eea6619f5943c64ced52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvis=20L=C4=81cis?= Date: Sun, 26 Jun 2022 18:39:18 +0300 Subject: [PATCH 3/3] Added test case for args with named array elements --- tests/Router/UrlGeneratorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Router/UrlGeneratorTest.php b/tests/Router/UrlGeneratorTest.php index 45b76f333..5ec7a9330 100644 --- a/tests/Router/UrlGeneratorTest.php +++ b/tests/Router/UrlGeneratorTest.php @@ -517,10 +517,12 @@ public function testQueryArgsArrayMatchLaravel() // Non url-encoded 'https://www.example.com/path?array[]=v1&array[]=v2', 'https://www.example.com/path?array[0]=v1&array[1]=v2', + 'https://www.example.com/path?array[k1]=v1&array[k2]=v2', // Already url-encoded 'https://www.example.com/path?array%5B%5D=v1&array%5B%5D=v2', 'https://www.example.com/path?array%5B0%5D=v1&array%5B1%5D=v2', + 'https://www.example.com/path?array%5Bk1%5D=v1&array%5Bk2%5D=v2', ]; foreach ($checkUrlsOnBoth as $url) {