From 63d45f8dedab741c09b7cff555388f9ebbeab11a Mon Sep 17 00:00:00 2001 From: Nicolas Buquet Date: Tue, 14 Jan 2025 12:35:18 +0100 Subject: [PATCH] Remove trailing slash at the end of identity server. Signed-off-by: Nicolas Buquet --- MatrixSDK/MXSession.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MatrixSDK/MXSession.m b/MatrixSDK/MXSession.m index 7f4ae3d2e..11e31f2f6 100644 --- a/MatrixSDK/MXSession.m +++ b/MatrixSDK/MXSession.m @@ -832,6 +832,15 @@ - (void)handleSyncResponse:(MXSyncResponse *)syncResponse - (void)setIdentityServer:(NSString *)identityServer andAccessToken:(NSString *)accessToken { + // Old Account data can have a trailing slash at the end of their Identity Server. + // Ths can lead to unrecognized URL on the backend (like on 'invite to room') because the URL is then constructed + // with a double slash in its path. + // This lead to error 500 for these calls. + // Sp, fix this trailing slash as soon as we receive it. + if ([identityServer hasSuffix:@"/"]) { + identityServer = [identityServer substringToIndex:identityServer.length-1]; + } + MXLogDebug(@"[MXSession] setIdentityServer: %@", identityServer); matrixRestClient.identityServer = identityServer;