Skip to content

Commit a1e741a

Browse files
committed
formatting
1 parent 42c67a1 commit a1e741a

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

Diff for: src/Illuminate/Http/RedirectResponse.php

+7-12
Original file line numberDiff line numberDiff line change
@@ -146,28 +146,23 @@ public function withErrors($provider, $key = 'default')
146146
}
147147

148148
/**
149-
* Add fragment identifier to the url.
149+
* Add a fragment identifier to the URL.
150150
*
151-
* @param string $fragmentIdentifier
151+
* @param string $fragment
152152
* @return $this
153153
*/
154-
public function withFragmentIdentifier($fragmentIdentifier)
154+
public function withFragment($fragment)
155155
{
156-
// Remove any existing fragment identifier
157-
$this->withoutFragmentIdentifier();
158-
159-
// Strip superfluous "#" from the beginning of the fragment identifier
160-
$fragmentIdentifier = Str::after($fragmentIdentifier, '#');
161-
162-
return $this->setTargetUrl($this->getTargetUrl()."#$fragmentIdentifier");
156+
return $this->withoutFragment()
157+
->setTargetUrl($this->getTargetUrl().'#'.Str::after($fragment, '#'));
163158
}
164159

165160
/**
166-
* Remove any fragment identifier from the response url.
161+
* Remove any fragment identifier from the response URL.
167162
*
168163
* @return $this
169164
*/
170-
public function withoutFragmentIdentifier()
165+
public function withoutFragment()
171166
{
172167
return $this->setTargetUrl(Str::before($this->getTargetUrl(), '#'));
173168
}

Diff for: tests/Http/HttpRedirectResponseTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ public function testFragmentIdentifierOnRedirect()
5656
{
5757
$response = new RedirectResponse('foo.bar');
5858

59-
$response->withFragmentIdentifier('foo');
59+
$response->withFragment('foo');
6060
$this->assertSame('foo', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));
6161

62-
$response->withFragmentIdentifier('#bar');
62+
$response->withFragment('#bar');
6363
$this->assertSame('bar', parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));
6464

65-
$response->withoutFragmentIdentifier();
65+
$response->withoutFragment();
6666
$this->assertNull(parse_url($response->getTargetUrl(), PHP_URL_FRAGMENT));
6767
}
6868

0 commit comments

Comments
 (0)