From d70bb874a27cf6ece188f4357fc75ae766b6b74b Mon Sep 17 00:00:00 2001 From: oguzhankoral Date: Tue, 2 Jul 2024 16:56:35 +0300 Subject: [PATCH] Use Uri for checks in GetAccounts function --- src/Speckle.Core/Credentials/AccountManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Speckle.Core/Credentials/AccountManager.cs b/src/Speckle.Core/Credentials/AccountManager.cs index 7457fa62..445b4d97 100644 --- a/src/Speckle.Core/Credentials/AccountManager.cs +++ b/src/Speckle.Core/Credentials/AccountManager.cs @@ -272,21 +272,25 @@ public static async Task UpgradeAccount(string id) await s_accountStorage.WriteComplete().ConfigureAwait(false); } + public static IEnumerable GetAccounts(string serverUrl) + { + return GetAccounts(new Uri(serverUrl)); + } + /// /// Returns all unique accounts matching the serverUrl provided. If an account exists on more than one server, /// typically because it has been migrated, then only the upgraded account (and therefore server) are returned. /// Accounts are deemed to be the same when the Account.Id matches. /// - /// - /// - public static IEnumerable GetAccounts(string serverUrl) + /// Uri for server. + public static IEnumerable GetAccounts(Uri serverUrl) { var accounts = GetAccounts().ToList(); List filtered = new(); foreach (var acc in accounts) { - if (acc.serverInfo?.migration?.movedFrom == new Uri(serverUrl)) + if (acc.serverInfo?.migration?.movedFrom == serverUrl) { filtered.Add(acc); } @@ -296,7 +300,7 @@ public static IEnumerable GetAccounts(string serverUrl) { // we use the userInfo to detect the same account rather than the account.id // which should NOT match for essentially the same accounts but on different servers - i.e. FE1 & FE2 - if (acc.serverInfo.url == serverUrl && !filtered.Any(x => x.userInfo.id == acc.userInfo.id)) + if (new Uri(acc.serverInfo.url) == serverUrl && !filtered.Any(x => x.userInfo.id == acc.userInfo.id)) { filtered.Add(acc); }