From 2fec3a41183d2abb3c36c91d118554589705c398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robbert=20M=C3=BCller?= Date: Thu, 7 Dec 2017 12:26:40 +0100 Subject: [PATCH] add testcase and fix for the bug --- src/Endpoint.php | 9 +++------ tests/EndpointTest.php | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Endpoint.php b/src/Endpoint.php index 2d244a1..3a0aa51 100644 --- a/src/Endpoint.php +++ b/src/Endpoint.php @@ -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; } } diff --git a/tests/EndpointTest.php b/tests/EndpointTest.php index d41111d..c951428 100644 --- a/tests/EndpointTest.php +++ b/tests/EndpointTest.php @@ -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'] ]; }