Skip to content

Commit

Permalink
Handle missing URL scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmccreary committed Oct 11, 2022
1 parent 1b85da7 commit b979027
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Models/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private static function parseData(array $data): array

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

if (isset($url['port'])) {
$output .= ':' . $url['port'];
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/Console/Commands/CurlCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function curlCommandFixtures()
'Initial connection timeout' => ['connect-timeout'],
'Entire transaction timeout' => ['max-timeout'],
'Ignore location flag' => ['ignore-location-flag'],
'Missing URL scheme' => ['missing-url-scheme'],
];
}

Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/missing-url-scheme.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
curl -X POST -d 'foo=bar' example.com
4 changes: 4 additions & 0 deletions tests/fixtures/missing-url-scheme.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Http::asForm()
->post('https://example.com', [
'foo' => 'bar',
]);

0 comments on commit b979027

Please sign in to comment.