From 95634fb3901d194348258ff5b055f968b5dd6db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Guti=C3=A9rrez?= Date: Sun, 17 Jan 2016 17:28:27 +0100 Subject: [PATCH] compound redirect uri with Psr\Http\Message\UriInterface --- src/Exception/OAuthServerException.php | 8 +++++- src/Utils/RedirectUri.php | 34 -------------------------- 2 files changed, 7 insertions(+), 35 deletions(-) delete mode 100644 src/Utils/RedirectUri.php diff --git a/src/Exception/OAuthServerException.php b/src/Exception/OAuthServerException.php index b0309290..936f41fd 100644 --- a/src/Exception/OAuthServerException.php +++ b/src/Exception/OAuthServerException.php @@ -6,6 +6,7 @@ use League\OAuth2\Server\Utils\RedirectUri; use Psr\Http\Message\ResponseInterface; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequest; +use Zend\Diactoros\Uri; class OAuthServerException extends \Exception { @@ -236,7 +237,12 @@ class OAuthServerException extends \Exception } if ($this->redirectUri !== null) { - $headers['Location'] = RedirectUri::make($this->redirectUri, $payload); + $redirectUri = new Uri($this->redirectUri); + parse_str($redirectUri->getQuery(), $redirectPayload); + + $headers['Location'] = (string) $redirectUri->withQuery(http_build_query( + array_merge($redirectPayload, $payload) + )); } foreach ($headers as $header => $content) { diff --git a/src/Utils/RedirectUri.php b/src/Utils/RedirectUri.php deleted file mode 100644 index d00f29cc..00000000 --- a/src/Utils/RedirectUri.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Copyright (c) Alex Bilbie - * @license http://mit-license.org/ - * @link https://github.com/thephpleague/oauth2-server - */ - -namespace League\OAuth2\Server\Utils; - -/** - * RedirectUri class - */ -class RedirectUri -{ - /** - * Generate a new redirect uri - * - * @param string $uri The base URI - * @param array $params The query string parameters - * @param string $queryDelimiter The query string delimiter (default: "?") - * - * @return string The updated URI - */ - public static function make($uri, $params = [], $queryDelimiter = '?') - { - $uri .= (strstr($uri, $queryDelimiter) === false) ? $queryDelimiter : '&'; - - return $uri . http_build_query($params); - } -}