Skip to content

Commit b979027

Browse files
committed
Handle missing URL scheme
1 parent 1b85da7 commit b979027

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

src/Models/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private static function parseData(array $data): array
173173

174174
private static function buildUrl(array $url): string
175175
{
176-
$output = $url['scheme'] . '://' . $url['host'];
176+
$output = ($url['scheme'] ?? 'https') . '://' . ($url['host'] ?? '');
177177

178178
if (isset($url['port'])) {
179179
$output .= ':' . $url['port'];

tests/Feature/Console/Commands/CurlCommandTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function curlCommandFixtures()
4141
'Initial connection timeout' => ['connect-timeout'],
4242
'Entire transaction timeout' => ['max-timeout'],
4343
'Ignore location flag' => ['ignore-location-flag'],
44+
'Missing URL scheme' => ['missing-url-scheme'],
4445
];
4546
}
4647

tests/fixtures/missing-url-scheme.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -X POST -d 'foo=bar' example.com

tests/fixtures/missing-url-scheme.out

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Http::asForm()
2+
->post('https://example.com', [
3+
'foo' => 'bar',
4+
]);

0 commit comments

Comments
 (0)