From 65d387a82346b73d14bfa16d236dc7a4260efd0a Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:06:49 -0500 Subject: [PATCH] Storage: Account for malformed team names in loading comparisons --- js/storage.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/storage.js b/js/storage.js index 20d8ca5783..7c8457b218 100644 --- a/js/storage.js +++ b/js/storage.js @@ -601,7 +601,7 @@ Storage.compareTeams = function (serverTeam, localTeam) { } } var sanitize = function (name) { - return (name || "").replace(' (server version)', '').trim(); + return (name || "").replace(/\s+\(server version\)/g, '').trim(); }; var nameMatches = sanitize(serverTeam.name) === sanitize(localTeam.name); if (!(nameMatches && serverTeam.format === localTeam.format)) { @@ -633,7 +633,9 @@ Storage.loadRemoteTeams = function (after) { } if (match === 'rename') { delete curTeam.teamid; - team.name += ' (server version)'; + if (!team.name.endsWith(' (server version)')) { + team.name += ' (server version)'; + } } } team.loaded = false;