From c71aa971a90dcc86a2a430a1753da3500a831e78 Mon Sep 17 00:00:00 2001 From: kiingxo Date: Thu, 17 Jul 2025 11:32:47 +0100 Subject: [PATCH] fix: allow both http and https for server URL, default to https if missing --- lib/screens/auth_screen.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/screens/auth_screen.dart b/lib/screens/auth_screen.dart index 1de4967b..9e3ffba9 100644 --- a/lib/screens/auth_screen.dart +++ b/lib/screens/auth_screen.dart @@ -38,6 +38,17 @@ enum AuthMode { Login, } +/// Ensures the server URL has a protocol. Defaults to https:// if none is specified. +String normalizeServerUrl(String url) { + if (url.isEmpty) return url; + url = url.trim(); + if (url.startsWith('http://') || url.startsWith('https://')) { + return url; + } + // Default to https if no protocol is specified + return 'https://$url'; +} + class AuthScreen extends StatelessWidget { const AuthScreen(); @@ -327,7 +338,7 @@ class _AuthCardState extends State { if (value!.lastIndexOf('/') == (value.length - 1)) { value = value.substring(0, value.lastIndexOf('/')); } - _authData['serverUrl'] = value; + _authData['serverUrl'] = normalizeServerUrl(value); }, ), ),