From 68a9694b3ac41c2f83bf431dbd48704ce4a66293 Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:43:41 -0500 Subject: [PATCH] Storage: Properly compare team names --- js/storage.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/storage.js b/js/storage.js index 359299f263..20d8ca5783 100644 --- a/js/storage.js +++ b/js/storage.js @@ -600,8 +600,11 @@ Storage.compareTeams = function (serverTeam, localTeam) { } } } - var localTeamName = localTeam.name.replace(' (server version)', ''); - if (!(serverTeam.name === localTeamName && serverTeam.format === localTeam.format)) { + var sanitize = function (name) { + return (name || "").replace(' (server version)', '').trim(); + }; + var nameMatches = sanitize(serverTeam.name) === sanitize(localTeam.name); + if (!(nameMatches && serverTeam.format === localTeam.format)) { return false; } // if it's been edited since, invalidate the team id on this one (count it as new)