Template gameName into player-settings as a data attribute to avoid potential security risks.

This commit is contained in:
Chris Wilson
2021-07-25 15:49:51 -04:00
parent 35b9e4768a
commit 610871c61b
3 changed files with 4 additions and 5 deletions

View File

@@ -1,8 +1,7 @@
let gameName = null;
window.addEventListener('load', () => {
const urlMatches = window.location.href.match(/^.*\/(.*)\/player-settings/);
gameName = decodeURIComponent(urlMatches[1]);
gameName = document.getElementById('player-settings').getAttribute('data-game');
// Update game name on page
document.getElementById('game-name').innerHTML = gameName;
@@ -25,7 +24,7 @@ window.addEventListener('load', () => {
nameInput.value = playerSettings.name;
}).catch((error) => {
const url = new URL(window.location.href);
window.location.replace(`${url.protocol}//${url.hostname}/page-not-found`);
// window.location.replace(`${url.protocol}//${url.hostname}/page-not-found`);
})
});