diff --git a/MatrixSDK/MXSession.m b/MatrixSDK/MXSession.m index 18550d042f..303531ce96 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. + // This 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 leads to error 500 for these calls. + // So, 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; diff --git a/changelog.d/pr-1898.change b/changelog.d/pr-1898.change new file mode 100644 index 0000000000..c3c51064fe --- /dev/null +++ b/changelog.d/pr-1898.change @@ -0,0 +1 @@ +Remove trailing slash at the end of identity server. \ No newline at end of file