Skip to content

Commit

Permalink
Revert "[10.x] Use fallback when previous URL is the same as the curr…
Browse files Browse the repository at this point in the history
…ent (#46234)"

This reverts commit 552f353.
  • Loading branch information
taylorotwell committed Mar 8, 2023
1 parent 46ecbca commit 825b75c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 0 additions & 26 deletions tests/Routing/RoutingUrlGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 825b75c

Please sign in to comment.