File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
apps/settings/lib/Controller Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -198,19 +198,24 @@ private function hasInternetConnectivityProblems(): bool {
198198 }
199199
200200 /**
201- * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
201+ * Checks if the Nextcloud server can connect to a specific URL
202+ * @param string $site site domain or full URL with http/https protocol
202203 * @return bool
203204 */
204- private function isSiteReachable ($ sitename ) {
205- $ httpSiteName = 'http:// ' . $ sitename . '/ ' ;
206- $ httpsSiteName = 'https:// ' . $ sitename . '/ ' ;
207-
205+ private function isSiteReachable (string $ site ): bool {
208206 try {
209207 $ client = $ this ->clientService ->newClient ();
210- $ client ->get ($ httpSiteName );
211- $ client ->get ($ httpsSiteName );
208+ // if there is no protocol, test http:// AND https://
209+ if (preg_match ('/^https?:\/\// ' , $ site ) !== 1 ) {
210+ $ httpSite = 'http:// ' . $ site . '/ ' ;
211+ $ client ->get ($ httpSite );
212+ $ httpsSite = 'https:// ' . $ site . '/ ' ;
213+ $ client ->get ($ httpsSite );
214+ } else {
215+ $ client ->get ($ site );
216+ }
212217 } catch (\Exception $ e ) {
213- $ this ->logger ->error ('Cannot connect to: ' . $ sitename , [
218+ $ this ->logger ->error ('Cannot connect to: ' . $ site , [
214219 'app ' => 'internet_connection_check ' ,
215220 'exception ' => $ e ,
216221 ]);
Original file line number Diff line number Diff line change 767767 * connection. If none of these hosts are reachable, the administration panel
768768 * will show a warning. Set to an empty list to not do any such checks (warning
769769 * will still be shown).
770+ * If no protocol is provided, both http and https will be tested.
771+ * For example, 'http://www.nextcloud.com' and 'https://www.nextcloud.com'
772+ * will be tested for 'www.nextcloud.com'
773+ * If a protocol is provided, only this one will be tested.
770774 *
771775 * Defaults to the following domains:
772776 *
You can’t perform that action at this time.
0 commit comments