Skip to content

Commit 6e0d82a

Browse files
committed
Profile viewer: Handle name having platform suffix
1 parent 9948fee commit 6e0d82a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

profile.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,15 @@ function makeSyndicateLogoElement(syndicate)
487487
};
488488
});
489489

490+
function sanitiseName(name)
491+
{
492+
if (name.charCodeAt(name.length - 1) >= 0xE000)
493+
{
494+
name = name.substr(0, name.length - 1);
495+
}
496+
return name;
497+
}
498+
490499
let lookup_in_progress = false;
491500
function doLookup()
492501
{
@@ -503,7 +512,7 @@ function doLookup()
503512
if (data)
504513
{
505514
window.profile = data;
506-
window.hashprefix = "account=" + encodeURIComponent(profile.Results[0].DisplayName) + "&platform=" + profile.platform + "&";
515+
window.hashprefix = "account=" + encodeURIComponent(sanitiseName(profile.Results[0].DisplayName)) + "&platform=" + profile.platform + "&";
507516
location.hash = hashprefix + "tab=fashion"; // default tab
508517
}
509518
else
@@ -519,7 +528,7 @@ function renderProfile()
519528
{
520529
document.querySelector("#status").classList.add("d-none");
521530

522-
document.getElementById("profile-name").textContent = profile.Results[0].DisplayName;
531+
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
523532
document.getElementById("mr").textContent = platformNames[profile.platform] + " Account, Mastery Rank " + (profile.Results[0].PlayerLevel ?? 0);
524533

525534
const accolades = [];

0 commit comments

Comments
 (0)