From ee88aaaa215faa605ea826ebc1f09f476037e849 Mon Sep 17 00:00:00 2001 From: Andrew <5755685+arnidan@users.noreply.github.com> Date: Wed, 30 Jul 2025 13:04:07 +0200 Subject: [PATCH 1/3] Add additional test cases for UrlGenerator in UrlGeneratorTest.php --- tests/UrlGeneratorTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/UrlGeneratorTest.php b/tests/UrlGeneratorTest.php index 43f1c10..a314680 100644 --- a/tests/UrlGeneratorTest.php +++ b/tests/UrlGeneratorTest.php @@ -16,6 +16,10 @@ public function testBasicGeneration() Request::create('http://www.example.com/') ); + $this->assertEquals('http://www.example.com/', $urlGenerator->to('/')); + $this->assertEquals('http://www.example.com/foo/', $urlGenerator->to('foo/')); + $this->assertEquals('http://www.example.com/foo/bar/', $urlGenerator->to('foo/bar/')); + $this->assertEquals('http://www.example.com/foo/bar', $urlGenerator->to('foo/bar')); $this->assertEquals('http://www.example.com/foo/bar/', $urlGenerator->to('foo/bar/')); $this->assertEquals('http://www.example.com/foo/bar/', $urlGenerator->to('foo/bar//')); From 91488fc84bcc8fd9043a64872b366151548cfe82 Mon Sep 17 00:00:00 2001 From: Andrew <5755685+arnidan@users.noreply.github.com> Date: Wed, 30 Jul 2025 13:08:25 +0200 Subject: [PATCH 2/3] Fix UrlGenerator to prevent adding a trailing slash for the root path --- src/UrlGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UrlGenerator.php b/src/UrlGenerator.php index 0a1080a..e7a5677 100644 --- a/src/UrlGenerator.php +++ b/src/UrlGenerator.php @@ -53,7 +53,7 @@ public function to($path, $extra = [], $secure = null) $url = parent::to($path, $extra, $secure); - if (Str::endsWith($path, '/')) { + if (Str::endsWith($path, '/') && $path !== '/') { return $url.'/'; } From 49f2dd34bbbd78460d3f8e8953dec6981c463701 Mon Sep 17 00:00:00 2001 From: Andrew <5755685+arnidan@users.noreply.github.com> Date: Wed, 30 Jul 2025 13:10:48 +0200 Subject: [PATCH 3/3] Remove redundant test case for UrlGenerator in UrlGeneratorTest.php --- tests/UrlGeneratorTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/UrlGeneratorTest.php b/tests/UrlGeneratorTest.php index a314680..4dba2e7 100644 --- a/tests/UrlGeneratorTest.php +++ b/tests/UrlGeneratorTest.php @@ -18,8 +18,6 @@ public function testBasicGeneration() $this->assertEquals('http://www.example.com/', $urlGenerator->to('/')); $this->assertEquals('http://www.example.com/foo/', $urlGenerator->to('foo/')); - $this->assertEquals('http://www.example.com/foo/bar/', $urlGenerator->to('foo/bar/')); - $this->assertEquals('http://www.example.com/foo/bar', $urlGenerator->to('foo/bar')); $this->assertEquals('http://www.example.com/foo/bar/', $urlGenerator->to('foo/bar/')); $this->assertEquals('http://www.example.com/foo/bar/', $urlGenerator->to('foo/bar//'));