Skip to content

Commit 45bec38

Browse files
committed
only string URL
1 parent 0de7964 commit 45bec38

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/Http/Response.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Cake\Http\CorsBuilder;
2323
use Cake\Http\Exception\NotFoundException;
2424
use Cake\Log\Log;
25-
use Cake\Routing\Router;
2625
use DateTime;
2726
use DateTimeZone;
2827
use InvalidArgumentException;
@@ -1990,25 +1989,23 @@ public function withLength($bytes)
19901989
* ### Examples
19911990
*
19921991
* ```
1993-
* $response = $response->withAddedLink('http://example.com', ['rel' => 'prev'])
1994-
* ->withAddedLink(['controller' => 'Posts', 'action' => 'view'], ['rel' => 'next']);
1992+
* $response = $response->withAddedLink('http://example.com?page=1', ['rel' => 'prev'])
1993+
* ->withAddedLink('http://example.com?page=3', ['rel' => 'next']);
19951994
* ```
19961995
*
19971996
* Will generate:
19981997
*
19991998
* ```
2000-
* Link: <http://example.com>; rel="prev"
2001-
* Link: </posts/view>; rel="next"
1999+
* Link: <http://example.com?page=1>; rel="prev"
2000+
* Link: <http://example.com?page=3>; rel="next"
20022001
* ```
20032002
*
2004-
* @param string|array $url link-value
2003+
* @param string $url link-value
20052004
* @param array $options link-param
20062005
* @return static
20072006
*/
20082007
public function withAddedLink($url, $options = [])
20092008
{
2010-
$url = '<' . Router::url($url) . '>';
2011-
20122009
$params = [];
20132010
foreach ($options as $key => $option) {
20142011
$params[] = $key . '="' . $option . '"';
@@ -2019,7 +2016,7 @@ public function withAddedLink($url, $options = [])
20192016
$param = '; ' . implode('; ', $params);
20202017
}
20212018

2022-
return $this->withAddedHeader('Link', $url . $param);
2019+
return $this->withAddedHeader('Link', '<' . $url . '>' . $param);
20232020
}
20242021

20252022
/**

tests/TestCase/Http/ResponseTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,6 @@ public function testWithAddedLink()
950950
$this->assertFalse($response->hasHeader('Link'), 'Old instance not modified');
951951
$this->assertEquals('<http://example.com>; rel="prev"', $new->getHeaderLine('Link'));
952952

953-
$new = $response->withAddedLink([], ['rel' => 'prev']);
954-
$this->assertEquals('</>; rel="prev"', $new->getHeaderLine('Link'));
955-
956953
$new = $response->withAddedLink('http://example.com');
957954
$this->assertEquals('<http://example.com>', $new->getHeaderLine('Link'));
958955

0 commit comments

Comments
 (0)