From a1e741a1709b3d4998995b76abd990a6c09a5841 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 23 Apr 2020 09:26:02 -0500 Subject: [PATCH] formatting --- src/Illuminate/Http/RedirectResponse.php | 19 +++++++------------ tests/Http/HttpRedirectResponseTest.php | 6 +++--- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/Illuminate/Http/RedirectResponse.php b/src/Illuminate/Http/RedirectResponse.php index d633e5e3d03b..7f256a399396 100755 --- a/src/Illuminate/Http/RedirectResponse.php +++ b/src/Illuminate/Http/RedirectResponse.php @@ -146,28 +146,23 @@ public function withErrors($provider, $key = 'default') } /** - * Add fragment identifier to the url. + * Add a fragment identifier to the URL. * - * @param string $fragmentIdentifier + * @param string $fragment * @return $this */ - public function withFragmentIdentifier($fragmentIdentifier) + public function withFragment($fragment) { - // Remove any existing fragment identifier - $this->withoutFragmentIdentifier(); - - // Strip superfluous "#" from the beginning of the fragment identifier - $fragmentIdentifier = Str::after($fragmentIdentifier, '#'); - - return $this->setTargetUrl($this->getTargetUrl()."#$fragmentIdentifier"); + return $this->withoutFragment() + ->setTargetUrl($this->getTargetUrl().'#'.Str::after($fragment, '#')); } /** - * Remove any fragment identifier from the response url. + * Remove any fragment identifier from the response URL. * * @return $this */ - public function withoutFragmentIdentifier() + public function withoutFragment() { return $this->setTargetUrl(Str::before($this->getTargetUrl(), '#')); } diff --git a/tests/Http/HttpRedirectResponseTest.php b/tests/Http/HttpRedirectResponseTest.php index 1eb6b3798d5b..5b369c0a02bd 100755 --- a/tests/Http/HttpRedirectResponseTest.php +++ b/tests/Http/HttpRedirectResponseTest.php @@ -56,13 +56,13 @@ public function testFragmentIdentifierOnRedirect() { $response = new RedirectResponse('foo.bar'); - $response->withFragmentIdentifier('foo'); + $response->withFragment('foo'); $this->assertSame('foo', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT)); - $response->withFragmentIdentifier('#bar'); + $response->withFragment('#bar'); $this->assertSame('bar', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT)); - $response->withoutFragmentIdentifier(); + $response->withoutFragment(); $this->assertNull(parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT)); }