Problem
The current method of parsing the username via URL path segments (window.location.pathname.split("/")) is fragile. It breaks if the URL structure changes, if there is a trailing slash, or if new sub-paths are added to your routing.
Requirement
Decouple the username from the URL entirely. You need a reliable "source of truth" for the current user's identity that the frontend can read regardless of how the URL is structured.
What is needed
- Inject the username: Pass the username from your backend into the HTML
<head> using a <meta> tag when the page loads.
- Centralize access: Create a single, small helper function that reads this meta tag.
- Replace old logic: Remove the URL parsing logic from all your individual files (
ranks.js, historical-graphs.js, etc.) and replace it with a call to this new helper function.
Problem
The current method of parsing the username via URL path segments (
window.location.pathname.split("/")) is fragile. It breaks if the URL structure changes, if there is a trailing slash, or if new sub-paths are added to your routing.Requirement
Decouple the username from the URL entirely. You need a reliable "source of truth" for the current user's identity that the frontend can read regardless of how the URL is structured.
What is needed
<head>using a<meta>tag when the page loads.ranks.js,historical-graphs.js, etc.) and replace it with a call to this new helper function.