Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 23, 2021
1 parent cd49e7e commit 732c0e0
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions src/Illuminate/Routing/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,9 @@ public function formatScheme($secure = null)
*/
public function signedRoute($name, $parameters = [], $expiration = null, $absolute = true)
{
$parameters = $this->formatParameters($parameters);

if (array_key_exists('signature', $parameters)) {
throw new InvalidArgumentException(
'"Signature" is a reserved parameter when generating signed routes. Please rename your route parameter.'
);
}

if (array_key_exists('expires', $parameters)) {
throw new InvalidArgumentException(
'"Expires" is a reserved parameter when generating signed routes. Please rename your route parameter.'
);
}
$this->ensureSignedRouteParametersAreNotReserved(
$parameters = $this->formatParameters($parameters)
);

if ($expiration) {
$parameters = $parameters + ['expires' => $this->availableAt($expiration)];
Expand All @@ -347,6 +337,27 @@ public function signedRoute($name, $parameters = [], $expiration = null, $absolu
], $absolute);
}

/**
* Ensure the given signed route parameters are not reserved.
*
* @param mixed $parameters
* @return void
*/
protected function ensureSignedRouteParametersAreNotReserved($parameters)
{
if (array_key_exists('signature', $parameters)) {
throw new InvalidArgumentException(
'"Signature" is a reserved parameter when generating signed routes. Please rename your route parameter.'
);
}

if (array_key_exists('expires', $parameters)) {
throw new InvalidArgumentException(
'"Expires" is a reserved parameter when generating signed routes. Please rename your route parameter.'
);
}
}

/**
* Create a temporary signed route URL for a named route.
*
Expand Down

0 comments on commit 732c0e0

Please sign in to comment.