From 4a51f3da0177deceb7b30ed3c2bff3fbacfd5614 Mon Sep 17 00:00:00 2001 From: Ashley Bailey Date: Wed, 8 Jan 2025 21:50:28 +0000 Subject: [PATCH 1/4] Automatically apply /api to server URL if missing --- mobile/lib/widgets/forms/login/login_form.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mobile/lib/widgets/forms/login/login_form.dart b/mobile/lib/widgets/forms/login/login_form.dart index 30b6a74bb137d..163c2058d5ab1 100644 --- a/mobile/lib/widgets/forms/login/login_form.dart +++ b/mobile/lib/widgets/forms/login/login_form.dart @@ -94,6 +94,16 @@ class LoginForm extends HookConsumerWidget { ); } + // Automatically add /api to URL + if (!serverUrl.endsWith('/api') && + !serverUrl.endsWith('/api/')) { + if (!serverUrl.endsWith('/')) { + serverUrl = String($sanitizedUrl + '/api/'); + } + serverUrl = String($sanitizedUrl + 'api/'); + } + + try { isLoadingServer.value = true; final endpoint = From ce691228e970aba72b54625532faa561b4d5552f Mon Sep 17 00:00:00 2001 From: Ashley Bailey Date: Wed, 8 Jan 2025 22:16:25 +0000 Subject: [PATCH 2/4] Automatically apply /api to server URL if missing --- mobile/lib/widgets/forms/login/login_form.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mobile/lib/widgets/forms/login/login_form.dart b/mobile/lib/widgets/forms/login/login_form.dart index 163c2058d5ab1..b8668e2fde862 100644 --- a/mobile/lib/widgets/forms/login/login_form.dart +++ b/mobile/lib/widgets/forms/login/login_form.dart @@ -98,9 +98,9 @@ class LoginForm extends HookConsumerWidget { if (!serverUrl.endsWith('/api') && !serverUrl.endsWith('/api/')) { if (!serverUrl.endsWith('/')) { - serverUrl = String($sanitizedUrl + '/api/'); + serverUrl = String($sanitizedUrl + '/api'); } - serverUrl = String($sanitizedUrl + 'api/'); + serverUrl = String($sanitizedUrl + 'api'); } From cd3962e7b3aec7dd262426deaab7ad38c3dbd956 Mon Sep 17 00:00:00 2001 From: Ashley Bailey Date: Wed, 8 Jan 2025 22:20:18 +0000 Subject: [PATCH 3/4] Automatically apply /api to server URL if missing --- mobile/lib/widgets/forms/login/login_form.dart | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mobile/lib/widgets/forms/login/login_form.dart b/mobile/lib/widgets/forms/login/login_form.dart index b8668e2fde862..c6b2a4c4897d5 100644 --- a/mobile/lib/widgets/forms/login/login_form.dart +++ b/mobile/lib/widgets/forms/login/login_form.dart @@ -94,9 +94,8 @@ class LoginForm extends HookConsumerWidget { ); } - // Automatically add /api to URL - if (!serverUrl.endsWith('/api') && - !serverUrl.endsWith('/api/')) { + // Automatically add /api to URL if missing + if (!serverUrl.endsWith('/api') || serverUrl.endsWith('/api/')) { if (!serverUrl.endsWith('/')) { serverUrl = String($sanitizedUrl + '/api'); } From 2d7fa205579559465abd5b888cb8d089e2df26bf Mon Sep 17 00:00:00 2001 From: Ashley Bailey Date: Wed, 8 Jan 2025 22:29:42 +0000 Subject: [PATCH 4/4] Automatically apply /api to server URL if missing --- mobile/lib/widgets/forms/login/login_form.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mobile/lib/widgets/forms/login/login_form.dart b/mobile/lib/widgets/forms/login/login_form.dart index c6b2a4c4897d5..df447d80cf023 100644 --- a/mobile/lib/widgets/forms/login/login_form.dart +++ b/mobile/lib/widgets/forms/login/login_form.dart @@ -94,12 +94,14 @@ class LoginForm extends HookConsumerWidget { ); } - // Automatically add /api to URL if missing - if (!serverUrl.endsWith('/api') || serverUrl.endsWith('/api/')) { - if (!serverUrl.endsWith('/')) { - serverUrl = String($sanitizedUrl + '/api'); - } - serverUrl = String($sanitizedUrl + 'api'); + // Automatically add /api to serverUrl if missing + serverUrl = serverUrl.trim(); + + // Check if the string ends with '/api/' and remove the trailing slash if it does or add '/api' if the string doesn't end with '/api' + if (serverUrl.endsWith('/api/')) { + serverUrl = serverUrl.substring(0, serverUrl.length - 1); + } else if (!serverUrl.endsWith('/api')) { + serverUrl = '$serverUrl/api'; }