From b356cba2a64b841c8c8f2c3f518bdc5f9464a95a Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Tue, 17 Dec 2024 15:23:59 +0100 Subject: [PATCH] fix: make sure we have a valid scheme when testing ocm urls Signed-off-by: skjnldsv --- lib/private/OCM/OCMDiscoveryService.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/private/OCM/OCMDiscoveryService.php b/lib/private/OCM/OCMDiscoveryService.php index 377861b2eef07..1fda1b1dac14e 100644 --- a/lib/private/OCM/OCMDiscoveryService.php +++ b/lib/private/OCM/OCMDiscoveryService.php @@ -9,6 +9,7 @@ namespace OC\OCM; +use GuzzleHttp\Exception\ConnectException; use JsonException; use OCP\AppFramework\Http; use OCP\Http\Client\IClientService; @@ -52,6 +53,14 @@ public function __construct( */ public function discover(string $remote, bool $skipCache = false): IOCMProvider { $remote = rtrim($remote, '/'); + if (!str_starts_with($remote, 'http://') && !str_starts_with($remote, 'https://')) { + // if scheme not specified, we test both; + try { + return $this->discover('https://' . $remote, $skipCache); + } catch (OCMProviderException|ConnectException) { + return $this->discover('http://' . $remote, $skipCache); + } + } if (!$skipCache) { try {