From 6e0d82a2b0fed703c6df67ff40057e42b535ca07 Mon Sep 17 00:00:00 2001 From: Sainan Date: Thu, 10 Oct 2024 14:04:03 +0200 Subject: [PATCH] Profile viewer: Handle name having platform suffix --- profile.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/profile.php b/profile.php index 6a956bc..a25dfb5 100644 --- a/profile.php +++ b/profile.php @@ -487,6 +487,15 @@ function makeSyndicateLogoElement(syndicate) }; }); + function sanitiseName(name) + { + if (name.charCodeAt(name.length - 1) >= 0xE000) + { + name = name.substr(0, name.length - 1); + } + return name; + } + let lookup_in_progress = false; function doLookup() { @@ -503,7 +512,7 @@ function doLookup() if (data) { window.profile = data; - window.hashprefix = "account=" + encodeURIComponent(profile.Results[0].DisplayName) + "&platform=" + profile.platform + "&"; + window.hashprefix = "account=" + encodeURIComponent(sanitiseName(profile.Results[0].DisplayName)) + "&platform=" + profile.platform + "&"; location.hash = hashprefix + "tab=fashion"; // default tab } else @@ -519,7 +528,7 @@ function renderProfile() { document.querySelector("#status").classList.add("d-none"); - document.getElementById("profile-name").textContent = profile.Results[0].DisplayName; + document.getElementById("profile-name").textContent = sanitiseName(profile.Results[0].DisplayName); // Note: In case the name needs to be sanitised, there is also a "PlatformNames" field. Example user: Voltage document.getElementById("mr").textContent = platformNames[profile.platform] + " Account, Mastery Rank " + (profile.Results[0].PlayerLevel ?? 0); const accolades = [];