remove end slash when setting server config (#8779)

Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
21pages 2024-07-22 17:11:32 +08:00 committed by GitHub
parent 22f3425ace
commit 14b505130b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3098,9 +3098,16 @@ Future<bool> setServerConfig(
List<RxString>? errMsgs,
ServerConfig config,
) async {
config.idServer = config.idServer.trim();
config.relayServer = config.relayServer.trim();
config.apiServer = config.apiServer.trim();
String removeEndSlash(String input) {
if (input.endsWith('/')) {
return input.substring(0, input.length - 1);
}
return input;
}
config.idServer = removeEndSlash(config.idServer.trim());
config.relayServer = removeEndSlash(config.relayServer.trim());
config.apiServer = removeEndSlash(config.apiServer.trim());
config.key = config.key.trim();
if (controllers != null) {
controllers[0].text = config.idServer;