Skip to content

Commit bcb133e

Browse files
committed
fix signed urls with custom parameters
1 parent dc3ad68 commit bcb133e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Illuminate/Routing/UrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public function formatScheme($secure = null)
320320
*/
321321
public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true)
322322
{
323-
$parameters = $this->formatParameters($parameters);
323+
$parameters = Arr::wrap($parameters);
324324

325325
if (array_key_exists('signature', $parameters)) {
326326
throw new InvalidArgumentException(

tests/Integration/Routing/UrlSigningTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ public function testSigningUrl()
2525
$this->assertSame('valid', $this->get($url)->original);
2626
}
2727

28+
public function testSigningUrlWithCustomRouteSlug()
29+
{
30+
Route::get('/foo/{post:slug}', function (Request $request, $slug) {
31+
return ['slug' => $slug, 'valid' => $request->hasValidSignature() ? 'valid' : 'invalid'];
32+
})->name('foo');
33+
34+
$this->assertIsString($url = URL::signedRoute('foo', ['post' => new RoutableInterfaceStub]));
35+
$this->assertSame('valid', $this->get($url)->original['valid']);
36+
$this->assertSame('routable-slug', $this->get($url)->original['slug']);
37+
}
38+
2839
public function testTemporarySignedUrls()
2940
{
3041
Route::get('/foo/{id}', function (Request $request, $id) {
@@ -90,6 +101,7 @@ public function testSignedMiddlewareWithRoutableParameter()
90101
class RoutableInterfaceStub implements UrlRoutable
91102
{
92103
public $key;
104+
public $slug = 'routable-slug';
93105

94106
public function getRouteKey()
95107
{

0 commit comments

Comments
 (0)