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

Commit 6131fc6

Browse files
authored
Merge pull request #4 from mjrider/endpoint-parse-errro-fix
Bugfix: fix issue in url parsing
2 parents ebd6a45 + 2fec3a4 commit 6131fc6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/Endpoint.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,13 @@ trait Endpoint
1616
*/
1717
public static function endpointToURL($endpoint)
1818
{
19-
if (strpos($endpoint, '://') === false && strpos('//', $endpoint) !== 0) {
19+
if (strpos($endpoint, '//') === 0) {
20+
$endpoint = 'https:'.$endpoint;
21+
} else if (strpos($endpoint, '://') === false) {
2022
$endpoint = 'https://'.$endpoint;
2123
}
2224

2325
$url = \arc\url::url($endpoint);
24-
25-
if ($url->scheme == '') {
26-
$url->scheme = 'https';
27-
}
28-
2926
return (string)$url;
3027
}
3128
}

tests/EndpointTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function endpointProvider()
2626
['example.com', 'https://example.com'],
2727
['example.com/v1', 'https://example.com/v1'],
2828
['example.com:1443/v1', 'https://example.com:1443/v1'],
29+
['//example.com/v1', 'https://example.com/v1'],
2930
['http://example.com:8080/v1']
3031
];
3132
}

0 commit comments

Comments
 (0)