From 825b75c2314e7e33a50b3bc7962670453550af78 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 7 Mar 2023 20:43:10 -0600 Subject: [PATCH] Revert "[10.x] Use fallback when previous URL is the same as the current (#46234)" This reverts commit 552f353676f50228f639955421d4d1ca9faca689. --- src/Illuminate/Routing/UrlGenerator.php | 2 +- tests/Routing/RoutingUrlGeneratorTest.php | 26 ----------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/Illuminate/Routing/UrlGenerator.php b/src/Illuminate/Routing/UrlGenerator.php index 78c95844ce42..105d17b658c3 100755 --- a/src/Illuminate/Routing/UrlGenerator.php +++ b/src/Illuminate/Routing/UrlGenerator.php @@ -158,7 +158,7 @@ public function previous($fallback = false) $url = $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession(); - if ($url && rtrim($url, '/') !== $this->request->fullUrl()) { + if ($url) { return $url; } elseif ($fallback) { return $this->to($fallback); diff --git a/tests/Routing/RoutingUrlGeneratorTest.php b/tests/Routing/RoutingUrlGeneratorTest.php index f200771a5eb0..9909f9c06392 100755 --- a/tests/Routing/RoutingUrlGeneratorTest.php +++ b/tests/Routing/RoutingUrlGeneratorTest.php @@ -734,32 +734,6 @@ public function testPreviousPath() $this->assertSame('/bar', $url->previousPath('/bar')); } - public function testWhenPreviousIsEqualToCurrent() - { - $url = new UrlGenerator( - new RouteCollection, - Request::create('http://www.foo.com/') - ); - - $url->getRequest()->headers->set('referer', 'http://www.foo.com/'); - $this->assertSame('http://www.foo.com', $url->previous()); - $this->assertSame('http://www.foo.com/bar', $url->previous('/bar')); - - $url->setRequest(Request::create('http://www.foo.com/bar')); - - $url->getRequest()->headers->set('referer', 'http://www.foo.com/bar'); - $this->assertSame('http://www.foo.com', $url->previous()); - $this->assertSame('http://www.foo.com/bar', $url->previous('/bar')); - $this->assertSame('http://www.foo.com/baz', $url->previous('/baz')); - - $url->setRequest(Request::create('http://www.foo.com/bar?page=2')); - - $url->getRequest()->headers->set('referer', 'http://www.foo.com/bar?page=2'); - $this->assertSame('http://www.foo.com', $url->previous()); - $this->assertSame('http://www.foo.com/bar', $url->previous('/bar')); - $this->assertSame('http://www.foo.com/bar?page=2', $url->previous('/bar?page=2')); - } - public function testRouteNotDefinedException() { $this->expectException(RouteNotFoundException::class);