Fix Query URL

This commit is contained in:
Michał Jusięga 2021-01-31 21:54:11 +01:00
parent 945c7c590c
commit 55831a85db
2 changed files with 7 additions and 0 deletions

View File

@ -422,6 +422,10 @@ trait HttpClientTrait
$url['path'] = '/'; $url['path'] = '/';
} }
if ('?' === ($url['query'] ?? '')) {
$url['query'] = null;
}
return $url; return $url;
} }

View File

@ -44,6 +44,9 @@ class HttpClientTraitTest extends TestCase
yield ['http://example.com/?a=2&b=b', '.?a=2']; yield ['http://example.com/?a=2&b=b', '.?a=2'];
yield ['http://example.com/?a=3&b=b', '.', ['a' => 3]]; yield ['http://example.com/?a=3&b=b', '.', ['a' => 3]];
yield ['http://example.com/?a=3&b=b', '.?a=0', ['a' => 3]]; yield ['http://example.com/?a=3&b=b', '.?a=0', ['a' => 3]];
yield ['http://example.com/', 'http://example.com/', ['a' => null]];
yield ['http://example.com/?b=', 'http://example.com/', ['b' => '']];
yield ['http://example.com/?b=', 'http://example.com/', ['a' => null, 'b' => '']];
} }
/** /**