From 57b5a71d148eeee0b70b0c696270075a8719fe44 Mon Sep 17 00:00:00 2001 From: Ali Khalili Date: Sat, 2 Nov 2019 11:15:56 +0330 Subject: [PATCH 1/2] setting query parameters if exists in target URL --- src/Proxy.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Proxy.php b/src/Proxy.php index 28ee3df..507edbd 100644 --- a/src/Proxy.php +++ b/src/Proxy.php @@ -74,6 +74,11 @@ public function to($target) $uri = $uri->withPath(rtrim($path, '/') . '/' . ltrim($uri->getPath(), '/')); } + //check for query parameters. + if ($query = $target->getQuery()) { + $uri = $uri->withQuery($query); + } + $request = $this->request->withUri($uri); $stack = $this->filters; From b4d6b23d78d54fd3ce7d4a1d32f165dbbe84bf76 Mon Sep 17 00:00:00 2001 From: Ali Khalili Date: Sat, 8 Feb 2020 12:20:40 +0330 Subject: [PATCH 2/2] avoid adding trailing slash to path in to(target) function --- src/Proxy.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Proxy.php b/src/Proxy.php index 507edbd..1bf5026 100644 --- a/src/Proxy.php +++ b/src/Proxy.php @@ -71,7 +71,8 @@ public function to($target) // Check for subdirectory. if ($path = $target->getPath()) { - $uri = $uri->withPath(rtrim($path, '/') . '/' . ltrim($uri->getPath(), '/')); + $uriPath = ltrim($uri->getPath(), '/'); + $uri = $uri->withPath(rtrim($path, '/') . (!empty($uriPath) ? ('/' . ltrim($uri->getPath(), '/')) : '')); } //check for query parameters.