diff --git a/src/Plugin/Alipay/HtmlResponsePlugin.php b/src/Plugin/Alipay/HtmlResponsePlugin.php
index 7a8af8e..898be61 100644
--- a/src/Plugin/Alipay/HtmlResponsePlugin.php
+++ b/src/Plugin/Alipay/HtmlResponsePlugin.php
@@ -9,7 +9,6 @@ use GuzzleHttp\Psr7\Response;
use Yansongda\Pay\Contract\PluginInterface;
use Yansongda\Pay\Logger;
use Yansongda\Pay\Rocket;
-use Yansongda\Supports\Arr;
use Yansongda\Supports\Collection;
class HtmlResponsePlugin implements PluginInterface
@@ -36,7 +35,7 @@ class HtmlResponsePlugin implements PluginInterface
protected function buildRedirect(string $endpoint, Collection $payload): Response
{
- $url = $endpoint.'?'.Arr::query($payload->all());
+ $url = $endpoint.(false === strpos($endpoint, '?') ? '?' : '&').$payload->query();
$content = sprintf('
diff --git a/tests/Plugin/Alipay/HtmlResponsePluginTest.php b/tests/Plugin/Alipay/HtmlResponsePluginTest.php
index 558f36f..afd23a9 100644
--- a/tests/Plugin/Alipay/HtmlResponsePluginTest.php
+++ b/tests/Plugin/Alipay/HtmlResponsePluginTest.php
@@ -25,6 +25,20 @@ class HtmlResponsePluginTest extends TestCase
self::assertEquals('https://yansongda.cn?name=yansongda', $result->getDestination()->getHeaderLine('Location'));
}
+ public function testRedirectIncludeMark()
+ {
+ $rocket = new Rocket();
+ $rocket->setRadar(new Request('GET', 'https://yansongda.cn?charset=utf8'))
+ ->setPayload(new Collection(['name' => 'yansongda']));
+
+ $plugin = new HtmlResponsePlugin();
+ $result = $plugin->assembly($rocket, function ($rocket) { return $rocket; });
+
+ self::assertInstanceOf(ResponseInterface::class, $result->getDestination());
+ self::assertArrayHasKey('Location', $result->getDestination()->getHeaders());
+ self::assertEquals('https://yansongda.cn?charset=utf8&name=yansongda', $result->getDestination()->getHeaderLine('Location'));
+ }
+
public function testHtml()
{
$rocket = new Rocket();