Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Bugfix: fix issue in url parsing #4

Merged
merged 1 commit into from
Dec 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ trait Endpoint
*/
public static function endpointToURL($endpoint)
{
if (strpos($endpoint, '://') === false && strpos('//', $endpoint) !== 0) {
if (strpos($endpoint, '//') === 0) {
$endpoint = 'https:'.$endpoint;
} else if (strpos($endpoint, '://') === false) {
$endpoint = 'https://'.$endpoint;
}

$url = \arc\url::url($endpoint);

if ($url->scheme == '') {
$url->scheme = 'https';
}

return (string)$url;
}
}
1 change: 1 addition & 0 deletions tests/EndpointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function endpointProvider()
['example.com', 'https://example.com'],
['example.com/v1', 'https://example.com/v1'],
['example.com:1443/v1', 'https://example.com:1443/v1'],
['//example.com/v1', 'https://example.com/v1'],
['http://example.com:8080/v1']
];
}
Expand Down