Skip to content

Commit

Permalink
Profile viewer: Handle name having platform suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Oct 10, 2024
1 parent 9948fee commit 6e0d82a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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
Expand All @@ -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 = [];
Expand Down

0 comments on commit 6e0d82a

Please sign in to comment.