Skip to content

Commit

Permalink
fix signed urls with custom parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 1, 2020
1 parent dc3ad68 commit bcb133e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function formatScheme($secure = null)
*/
public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true)
{
$parameters = $this->formatParameters($parameters);
$parameters = Arr::wrap($parameters);

if (array_key_exists('signature', $parameters)) {
throw new InvalidArgumentException(
Expand Down
12 changes: 12 additions & 0 deletions tests/Integration/Routing/UrlSigningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public function testSigningUrl()
$this->assertSame('valid', $this->get($url)->original);
}

public function testSigningUrlWithCustomRouteSlug()
{
Route::get('/foo/{post:slug}', function (Request $request, $slug) {
return ['slug' => $slug, 'valid' => $request->hasValidSignature() ? 'valid' : 'invalid'];
})->name('foo');

$this->assertIsString($url = URL::signedRoute('foo', ['post' => new RoutableInterfaceStub]));
$this->assertSame('valid', $this->get($url)->original['valid']);
$this->assertSame('routable-slug', $this->get($url)->original['slug']);
}

public function testTemporarySignedUrls()
{
Route::get('/foo/{id}', function (Request $request, $id) {
Expand Down Expand Up @@ -90,6 +101,7 @@ public function testSignedMiddlewareWithRoutableParameter()
class RoutableInterfaceStub implements UrlRoutable
{
public $key;
public $slug = 'routable-slug';

public function getRouteKey()
{
Expand Down

0 comments on commit bcb133e

Please sign in to comment.